Skip to content

Commit 60ae63e

Browse files
bcodding-rhgregkh
authored andcommitted
NFSv42: Fix pagecache invalidation after COPY/CLONE
commit 3f015d8 upstream. The mechanism in use to allow the client to see the results of COPY/CLONE is to drop those pages from the pagecache. This forces the client to read those pages once more from the server. However, truncate_pagecache_range() zeros out partial pages instead of dropping them. Let us instead use invalidate_inode_pages2_range() with full-page offsets to ensure the client properly sees the results of COPY/CLONE operations. Cc: <stable@vger.kernel.org> # v4.7+ Fixes: 2e72448 ("NFS: Add COPY nfs operation") Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a324ad7 commit 60ae63e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎fs/nfs/nfs42proc.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,9 @@ static ssize_t _nfs42_proc_copy(struct file *src,
362362
goto out;
363363
}
364364

365-
truncate_pagecache_range(dst_inode, pos_dst,
366-
pos_dst + res->write_res.count);
365+
WARN_ON_ONCE(invalidate_inode_pages2_range(dst_inode->i_mapping,
366+
pos_dst >> PAGE_SHIFT,
367+
(pos_dst + res->write_res.count - 1) >> PAGE_SHIFT));
367368
spin_lock(&dst_inode->i_lock);
368369
NFS_I(dst_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
369370
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_SIZE |

0 commit comments

Comments
 (0)