diff mbox series

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

Message ID 20240828210249.1078637-5-dhowells@redhat.com
State New
Headers show
Series mm, netfs, cifs: Miscellaneous fixes | expand

Commit Message

David Howells Aug. 28, 2024, 9:02 p.m. UTC
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@redhat.com>
cc: Matthew Wilcox <willy@infradead.org>
cc: Miklos Szeredi <miklos@szeredi.hu>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Andrew Morton <akpm@linux-foundation.org>
cc: Alexander Viro <viro@zeniv.linux.org.uk>
cc: Christian Brauner <brauner@kernel.org>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-mm@kvack.org
cc: linux-fsdevel@vger.kernel.org
cc: netfs@lists.linux.dev
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-nfs@vger.kernel.org
cc: devel@lists.orangefs.org
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Brauner Aug. 30, 2024, 1:12 p.m. UTC | #1
On Wed, 28 Aug 2024 22:02:45 +0100, David Howells wrote:
> 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.
> 
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[4/6] mm: Fix filemap_invalidate_inode() to use invalidate_inode_pages2_range()
      https://git.kernel.org/vfs/vfs/c/c26096ee0278
Steve French Sept. 1, 2024, 11:41 p.m. UTC | #2
This looks like an important one as it fixes multiple xfstests see e.g.
with the patch:
http://smb311-linux-testing.southcentralus.cloudapp.azure.com/#/builders/3/builds/213
vs without
http://smb311-linux-testing.southcentralus.cloudapp.azure.com/#/builders/3/builds/212

Can add:
Tested--by: Steve French <stfrench@microsoft.com>

On Fri, Aug 30, 2024 at 8:12 AM Christian Brauner <brauner@kernel.org> wrote:
>
> On Wed, 28 Aug 2024 22:02:45 +0100, David Howells wrote:
> > 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.
> >
> > [...]
>
> Applied to the vfs.fixes branch of the vfs/vfs.git tree.
> Patches in the vfs.fixes branch should appear in linux-next soon.
>
> Please report any outstanding bugs that were missed during review in a
> new review to the original patch series allowing us to drop it.
>
> It's encouraged to provide Acked-bys and Reviewed-bys even though the
> patch has now been applied. If possible patch trailers will be updated.
>
> Note that commit hashes shown below are subject to change due to rebase,
> trailer updates or similar. If in doubt, please check the listed branch.
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
> branch: vfs.fixes
>
> [4/6] mm: Fix filemap_invalidate_inode() to use invalidate_inode_pages2_range()
>       https://git.kernel.org/vfs/vfs/c/c26096ee0278
>
diff mbox series

Patch

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);