[PATCH 4/6] mm: Fix filemap_invalidate_inode() to use invalidate_inode_pages2_range()

David Howells dhowells at redhat.com
Thu Aug 29 07:02:45 AEST 2024


Fix filemap_invalidate_inode() to use invalidate_inode_pages2_range()
rather than truncate_inode_pages_range().  The latter clears the
invalidated bit of a partial pages rather than discarding it entirely.
This causes copy_file_range() to fail on cifs because the partial pages at
either end of the destination range aren't evicted and reread, but rather
just partly cleared.

This causes generic/075 and generic/112 xfstests to fail.

Fixes: 74e797d79cf1 ("mm: Provide a means of invalidation without using launder_folio")
Signed-off-by: David Howells <dhowells at redhat.com>
cc: Matthew Wilcox <willy at infradead.org>
cc: Miklos Szeredi <miklos at szeredi.hu>
cc: Trond Myklebust <trond.myklebust at hammerspace.com>
cc: Christoph Hellwig <hch at lst.de>
cc: Andrew Morton <akpm at linux-foundation.org>
cc: Alexander Viro <viro at zeniv.linux.org.uk>
cc: Christian Brauner <brauner at kernel.org>
cc: Jeff Layton <jlayton at kernel.org>
cc: linux-mm at kvack.org
cc: linux-fsdevel at vger.kernel.org
cc: netfs at lists.linux.dev
cc: v9fs at lists.linux.dev
cc: linux-afs at lists.infradead.org
cc: ceph-devel at vger.kernel.org
cc: linux-cifs at vger.kernel.org
cc: linux-nfs at vger.kernel.org
cc: devel at lists.orangefs.org
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index d62150418b91..0ca9c1377b68 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -4231,7 +4231,7 @@ int filemap_invalidate_inode(struct inode *inode, bool flush,
 	}
 
 	/* Wait for writeback to complete on all folios and discard. */
-	truncate_inode_pages_range(mapping, start, end);
+	invalidate_inode_pages2_range(mapping, start / PAGE_SIZE, end / PAGE_SIZE);
 
 unlock:
 	filemap_invalidate_unlock(mapping);



More information about the Linux-erofs mailing list