Linux-NFS Archive mirror
 help / color / mirror / Atom feed
From: Olga Kornievskaia <okorniev@redhat.com>
To: trondmy@kernel.org, anna@kernel.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v4 1/1] NFSv4.2: fix CLONE/COPY attrs in presence of delegated attributes
Date: Fri, 17 Apr 2026 14:46:56 -0400	[thread overview]
Message-ID: <20260417184656.36191-1-okorniev@redhat.com> (raw)

xfstest generic/407 is failing in 2 ways. It detects that after
doing a clone the client does not update it's mtime and it's ctime.
CLONE always sends a GETATTR operation and then calls
nfs_post_op_update_inode() based on the returned attributes.
Because of the delegated attributes the client ignores updating
the mtime. Then also, when delegated attributes are present, for
the change_attr the server replies with the same values as what
the client cached before and thus the generic/407 would flag that.
Instead, make sure we invalidate the blocks attr.

By adding updating delegated attributes in nfs42_copy_dest_done()
both COPY and CLONE would update mtime appropriately.

Fixes: e12912d94137 ("NFSv4: Add support for delegated atime and mtime attributes")
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>

--v4 this version removes the need for having
"NFSv4.2: fix COPY attrs in presence of delegated timestamps"
---
 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 7b3ca68fb4bb..fad0784349c7 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -393,6 +393,7 @@ static void nfs42_copy_dest_done(struct file *file, loff_t pos, loff_t len,
 	WARN_ON_ONCE(invalidate_inode_pages2_range(mapping, pos >> PAGE_SHIFT,
 						   end >> PAGE_SHIFT));
 
+	nfs_update_delegated_mtime(inode);
 	spin_lock(&inode->i_lock);
 	if (newsize > i_size_read(inode))
 		i_size_write(inode, newsize);
@@ -1306,7 +1307,14 @@ static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f,
 		if (count == 0 && res.dst_fattr->valid & NFS_ATTR_FATTR_SIZE)
 			count = nfs_size_to_loff_t(res.dst_fattr->size) - dst_offset;
 		nfs42_copy_dest_done(dst_f, dst_offset, count, oldsize_dst);
-		status = nfs_post_op_update_inode(dst_inode, res.dst_fattr);
+		if (!nfs_have_delegated_attributes(dst_inode))
+			status = nfs_post_op_update_inode(dst_inode,
+							  res.dst_fattr);
+		else {
+			spin_lock(&dst_inode->i_lock);
+			nfs_set_cache_invalid(dst_inode, NFS_INO_INVALID_BLOCKS);
+			spin_unlock(&dst_inode->i_lock);
+		}
 	}
 
 	kfree(res.dst_fattr);
-- 
2.52.0


                 reply	other threads:[~2026-04-17 18:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260417184656.36191-1-okorniev@redhat.com \
    --to=okorniev@redhat.com \
    --cc=anna@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).