summaryrefslogtreecommitdiff
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorHugh Dickins <hughd@google.com>2023-08-09 07:36:12 +0300
committerChristian Brauner <brauner@kernel.org>2023-08-11 14:48:55 +0300
commitaa5b9178c01905d7691512b366cf2886dfe2680c (patch)
tree4dd2da8a378a7fcce399743af00bc3e8d0bb5f79 /mm/shmem.c
parente88e0d366f9cfbb810b0c8509dc5d130d5a53e02 (diff)
downloadlinux-aa5b9178c01905d7691512b366cf2886dfe2680c.tar.xz
mm: invalidation check mapping before folio_contains
Enabling tmpfs "direct IO" exposes it to invalidate_inode_pages2_range(), which when swapping can hit the VM_BUG_ON_FOLIO(!folio_contains()): the folio has been moved from page cache to swap cache (with folio->mapping reset to NULL), but the folio_index() embedded in folio_contains() sees swapcache, and so returns the swapcache_index() - whereas folio->index would be the right one to check against the index from mapping's xarray. There are different ways to fix this, but my preference is just to order the checks in invalidate_inode_pages2_range() the same way that they are in __filemap_get_folio() and find_lock_entries() and filemap_fault(): check folio->mapping before folio_contains(). Signed-off-by: Hugh Dickins <hughd@google.com> Reviewed-by: Jan Kara <jack@suse.cz> Message-Id: <f0b31772-78d7-f198-6482-9f25aab8c13f@google.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'mm/shmem.c')
0 files changed, 0 insertions, 0 deletions