XArray: Update the LRU list in xas_split()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 31 Mar 2022 12:27:09 +0000 (08:27 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:40:40 +0000 (14:40 +0200)
commit381636f33fe4af41fec076c5d9346a7369bcb40e
tree8e01d3fb33b0c0419a80507e85cc4c10f92ceb84
parent3b9fabe8f6e80b884e830d3cf715be81534e8845
XArray: Update the LRU list in xas_split()

commit 3ed4bb77156da0bc732847c8c9df92454c1fbeea upstream.

When splitting a value entry, we may need to add the new nodes to the LRU
list and remove the parent node from the LRU list.  The WARN_ON checks
in shadow_lru_isolate() catch this oversight.  This bug was latent
until we stopped splitting folios in shrink_page_list() with commit
820c4e2e6f51 ("mm/vmscan: Free non-shmem folios without splitting them").
That allows the creation of large shadow entries, and subsequently when
trying to page in a small page, we will split the large shadow entry
in __filemap_add_folio().

Fixes: 8fc75643c5e1 ("XArray: add xas_split")
Reported-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/xarray.c