[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    NFSv4.2: fix client's attribute cache management for copy_file_range
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2020-09-28 18:16:09
Message-ID: git-mailbomb-linux-master-16abd2a0c124a6c3543c88ca4c53c997c9fb4114 () kernel ! org
[Download RAW message or body]

Commit:     16abd2a0c124a6c3543c88ca4c53c997c9fb4114
Parent:     d33030e2ee3508d65db5644551435310df86010e
Refname:    refs/heads/master
Web:        https://git.kernel.org/torvalds/c/16abd2a0c124a6c3543c88ca4c53c997c9fb4114
Author:     Olga Kornievskaia <kolga@netapp.com>
AuthorDate: Wed Sep 16 09:07:54 2020 -0400
Committer:  Trond Myklebust <trond.myklebust@hammerspace.com>
CommitDate: Wed Sep 16 12:25:14 2020 -0400

    NFSv4.2: fix client's attribute cache management for copy_file_range
    
    After client is done with the COPY operation, it needs to invalidate
    its pagecache (as it did no reading or writing of the data locally)
    and it needs to invalidate it's attributes just like it would have
    for a read on the source file and write on the destination file.
    
    Once the linux server started giving out read delegations to
    read+write opens, the destination file of the copy_file range
    started having delegations and not doing syncup on close of the
    file leading to xfstest failures for generic/430,431,432,433,565.
    
    v2: changing cache_validity needs to be protected by the i_lock.
    
    Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
    Fixes: 2e72448b07dc ("NFS: Add COPY nfs operation")
    Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs42proc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 142225f0af59..2b2211d1234e 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -356,7 +356,15 @@ static ssize_t _nfs42_proc_copy(struct file *src,
 
 	truncate_pagecache_range(dst_inode, pos_dst,
 				 pos_dst + res->write_res.count);
-
+	spin_lock(&dst_inode->i_lock);
+	NFS_I(dst_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
+			NFS_INO_REVAL_FORCED | NFS_INO_INVALID_SIZE |
+			NFS_INO_INVALID_ATTR | NFS_INO_INVALID_DATA);
+	spin_unlock(&dst_inode->i_lock);
+	spin_lock(&src_inode->i_lock);
+	NFS_I(src_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
+			NFS_INO_REVAL_FORCED | NFS_INO_INVALID_ATIME);
+	spin_unlock(&src_inode->i_lock);
 	status = res->write_res.count;
 out:
 	if (args->sync)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic