Commit 0aa2e1b2 authored by David Howells's avatar David Howells Committed by Christian Brauner

mm: Fix missing folio invalidation calls during truncation

When AS_RELEASE_ALWAYS is set on a mapping, the ->release_folio() and
->invalidate_folio() calls should be invoked even if PG_private and
PG_private_2 aren't set.  This is used by netfslib to keep track of the
point above which reads can be skipped in favour of just zeroing pagecache
locally.

There are a couple of places in truncation in which invalidation is only
called when folio_has_private() is true.  Fix these to check
folio_needs_release() instead.

Without this, the generic/075 and generic/112 xfstests (both fsx-based
tests) fail with minimum folio size patches applied[1].

Fixes: b4fa966f ("mm, netfs, fscache: stop read optimisation when folio removed from pagecache")
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20240815090849.972355-1-kernel@pankajraghav.com/ [1]
Link: https://lore.kernel.org/r/20240823200819.532106-2-dhowells@redhat.comReviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
cc: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: Pankaj Raghav <p.raghav@samsung.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: netfs@lists.linux.dev
cc: linux-mm@kvack.org
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent d10771d5
...@@ -157,7 +157,7 @@ static void truncate_cleanup_folio(struct folio *folio) ...@@ -157,7 +157,7 @@ static void truncate_cleanup_folio(struct folio *folio)
if (folio_mapped(folio)) if (folio_mapped(folio))
unmap_mapping_folio(folio); unmap_mapping_folio(folio);
if (folio_has_private(folio)) if (folio_needs_release(folio))
folio_invalidate(folio, 0, folio_size(folio)); folio_invalidate(folio, 0, folio_size(folio));
/* /*
...@@ -219,7 +219,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end) ...@@ -219,7 +219,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
if (!mapping_inaccessible(folio->mapping)) if (!mapping_inaccessible(folio->mapping))
folio_zero_range(folio, offset, length); folio_zero_range(folio, offset, length);
if (folio_has_private(folio)) if (folio_needs_release(folio))
folio_invalidate(folio, offset, length); folio_invalidate(folio, offset, length);
if (!folio_test_large(folio)) if (!folio_test_large(folio))
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment