mm/filemap: gate dropbehind invalidate on folio !dirty && !writeback
authorJens Axboe <axboe@kernel.dk>
Tue, 27 May 2025 01:03:27 +0000 (19:03 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 27 May 2025 13:17:04 +0000 (07:17 -0600)
commitccc40938c638267b220350ef3d4cb9b65aff38ca
tree1b8fe0e15c67d2057aeedf7794574a86e01b31c1
parent3349ada3cffdbe4579872a004360daa31938f683
mm/filemap: gate dropbehind invalidate on folio !dirty && !writeback

It's possible for the folio to either get marked for writeback or
redirtied. Add a helper, filemap_end_dropbehind(), which guards the
folio_unmap_invalidate() call behind check for the folio being both
non-dirty and not under writeback AFTER the folio lock has been
acquired. Use this helper folio_end_dropbehind_write().

Cc: stable@vger.kernel.org
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Fixes: fb7d3bc41493 ("mm/filemap: drop streaming/uncached pages when writeback completes")
Link: https://lore.kernel.org/linux-fsdevel/20250525083209.GS2023217@ZenIV/
Signed-off-by: Jens Axboe <axboe@kernel.dk>
mm/filemap.c