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 v2 3/3] nfsd: update mtime/ctime on asynchronous COPY with delegated attributes
Date: Wed, 8 Apr 2026 15:00:08 -0400 [thread overview]
Message-ID: <20260408190008.85082-4-okorniev@redhat.com> (raw)
In-Reply-To: <20260408190008.85082-1-okorniev@redhat.com>
Asynchronous COPY should update destination file's mtime/ctime upon
completion of copy work (not COPY compound processing).
Fixes: e5e9b24ab8fa ("nfsd: freeze c/mtime updates with outstanding WRITE_ATTRS delegation")
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
---
fs/nfsd/nfs4proc.c | 23 +++++++++++++++++++++--
fs/nfsd/xdr4.h | 1 +
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index ac47cddef384..b6490167e78b 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -2132,8 +2132,19 @@ static int nfsd4_do_async_copy(void *data)
set_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags);
trace_nfsd_copy_async_done(copy);
- nfsd4_send_cb_offload(copy);
atomic_dec(©->cp_nn->pending_async_copies);
+ /*
+ * choosing to check for existence of set dentry pointer to indicate
+ * that we need to update the attributes and do a dput because the
+ * file flag could be cleared by a DELEGRETURN and then we'd lose
+ * that copy was started with file opened with NOCMTIME and we got
+ * a reference on the dentry.
+ */
+ if (copy->d_dst && copy->cp_res.wr_bytes_written > 0) {
+ nfsd_update_cmtime_attr(copy->d_dst);
+ dput(copy->d_dst);
+ }
+ nfsd4_send_cb_offload(copy);
return 0;
}
@@ -2193,6 +2204,11 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
memcpy(&result->cb_stateid, ©->cp_stateid.cs_stid,
sizeof(result->cb_stateid));
dup_copy_fields(copy, async_copy);
+ if ((READ_ONCE(copy->nf_dst->nf_file->f_mode) &
+ FMODE_NOCMTIME) != 0) {
+ async_copy->d_dst = cstate->current_fh.fh_dentry;
+ dget(cstate->current_fh.fh_dentry);
+ }
memcpy(async_copy->cp_cb_offload.co_referring_sessionid.data,
cstate->session->se_sessionid.data,
NFS4_MAX_SESSIONID_LEN);
@@ -2221,8 +2237,11 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
release_copy_files(copy);
return status;
out_dec_async_copy_err:
- if (async_copy)
+ if (async_copy) {
atomic_dec(&nn->pending_async_copies);
+ if (async_copy->d_dst)
+ dput(cstate->current_fh.fh_dentry);
+ }
out_err:
if (nfsd4_ssc_is_inter(copy)) {
/*
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index 417e9ad9fbb3..ddd6e005d3cf 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -752,6 +752,7 @@ struct nfsd4_copy {
struct nfsd_file *nf_src;
struct nfsd_file *nf_dst;
+ struct dentry *d_dst;
copy_stateid_t cp_stateid;
--
2.52.0
next prev parent reply other threads:[~2026-04-08 19:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 19:00 [PATCH v2 0/3] nfsd update mtime/ctime on CLONE/COPY with delegated attritutes Olga Kornievskaia
2026-04-08 19:00 ` [PATCH v2 1/3] nfsd: update mtime/ctime on CLONE in presense of delegated attributes Olga Kornievskaia
2026-04-08 23:07 ` Chuck Lever
2026-04-09 14:12 ` Olga Kornievskaia
2026-04-08 19:00 ` [PATCH v2 2/3] nfsd: update mtime/ctime on synchronous COPY with " Olga Kornievskaia
2026-04-08 19:00 ` Olga Kornievskaia [this message]
2026-04-08 23:11 ` [PATCH v2 3/3] nfsd: update mtime/ctime on asynchronous " 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=20260408190008.85082-4-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).