public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Olga Kornievskaia <okorniev@redhat.com>
To: chuck.lever@oracle.com, jlayton@kernel.org
Cc: linux-nfs@vger.kernel.org, neilb@brown.name, Dai.Ngo@oracle.com,
	tom@talpey.com
Subject: [PATCH 1/1] nfsd: update mtime/ctime on CLONE and COPY in presence of delegated attributes
Date: Fri,  3 Apr 2026 12:53:35 -0400	[thread overview]
Message-ID: <20260403165335.73070-1-okorniev@redhat.com> (raw)

When delegated attributes are given on open the file is opened with NOCMTIME
and modifying operations do not update mtime/ctime as to not get out-of-sync
with the client's delegated view. However, for operations CLONE/COPY server
should update its view of mtime/ctime and reflect that in any GETATTR queries.

Fixes: e5e9b24ab8fa ("nfsd: freeze c/mtime updates with outstanding WRITE_ATTRS delegation")
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
---
 fs/nfsd/nfs4proc.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 99b44b6ec056..66bde3732b03 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1396,6 +1396,24 @@ nfsd4_verify_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	goto out;
 }
 
+static bool nfsd4_clear_nocmtime(struct file *f)
+{
+	if ((READ_ONCE(f->f_mode) & FMODE_NOCMTIME) != 0) {
+		spin_lock(&f->f_lock);
+		f->f_mode &= ~FMODE_NOCMTIME;
+		spin_unlock(&f->f_lock);
+		return true;
+	}
+	return false;
+}
+
+static void nfsd4_restore_nocmtime(struct file *f)
+{
+	spin_lock(&f->f_lock);
+	f->f_mode |= FMODE_NOCMTIME;
+	spin_unlock(&f->f_lock);
+}
+
 static __be32
 nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		union nfsd4_op_u *u)
@@ -1403,16 +1421,19 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	struct nfsd4_clone *clone = &u->clone;
 	struct nfsd_file *src, *dst;
 	__be32 status;
+	bool restore_nocmtime = false;
 
 	status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src,
 				   &clone->cl_dst_stateid, &dst);
 	if (status)
 		goto out;
 
+	restore_nocmtime = nfsd4_clear_nocmtime(dst->nf_file);
 	status = nfsd4_clone_file_range(rqstp, src, clone->cl_src_pos,
 			dst, clone->cl_dst_pos, clone->cl_count,
 			EX_ISSYNC(cstate->current_fh.fh_export));
-
+	if (restore_nocmtime)
+		nfsd4_restore_nocmtime(dst->nf_file);
 	nfsd_file_put(dst);
 	nfsd_file_put(src);
 out:
@@ -2132,6 +2153,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	struct nfsd4_copy *copy = &u->copy;
 	struct nfsd42_write_res *result;
 	__be32 status;
+	bool restore_nocmtime = false;
 
 	result = &copy->cp_res;
 	nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn);
@@ -2157,6 +2179,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		}
 	}
 
+	restore_nocmtime = nfsd4_clear_nocmtime(copy->nf_dst->nf_file);
 	memcpy(&copy->fh, &cstate->current_fh.fh_handle,
 		sizeof(struct knfsd_fh));
 	if (nfsd4_copy_is_async(copy)) {
@@ -2199,6 +2222,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 				       copy->nf_dst->nf_file, true);
 	}
 out:
+	if (restore_nocmtime)
+		nfsd4_restore_nocmtime(copy->nf_dst->nf_file);
 	trace_nfsd_copy_done(copy, status);
 	release_copy_files(copy);
 	return status;
-- 
2.52.0


             reply	other threads:[~2026-04-03 16:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03 16:53 Olga Kornievskaia [this message]
2026-04-03 17:00 ` [PATCH 1/1] nfsd: update mtime/ctime on CLONE and COPY in presence of delegated attributes Jeff Layton
2026-04-06 13:59   ` Olga Kornievskaia
2026-04-06 16:53     ` Jeff Layton
2026-04-04 15:01 ` Chuck Lever

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=20260403165335.73070-1-okorniev@redhat.com \
    --to=okorniev@redhat.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@brown.name \
    --cc=tom@talpey.com \
    /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