]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nfsd: update mtime/ctime on COPY in presence of delegated attributes
authorOlga Kornievskaia <okorniev@redhat.com>
Fri, 10 Apr 2026 16:09:20 +0000 (12:09 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 10 May 2026 16:41:03 +0000 (12:41 -0400)
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 COPY operation,
the 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")
Cc: stable@vger.kernel.org
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4proc.c
fs/nfsd/xdr4.h

index 5de8f37df78a299ef81e6671049431a186bcb43a..ab39ec8854405045cc582aac688572397ba74b0e 100644 (file)
@@ -2121,8 +2121,10 @@ do_callback:
 
        set_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags);
        trace_nfsd_copy_async_done(copy);
-       nfsd4_send_cb_offload(copy);
        atomic_dec(&copy->cp_nn->pending_async_copies);
+       if (copy->cp_res.wr_bytes_written > 0 && copy->attr_update)
+               nfsd_update_cmtime_attr(copy->nf_dst->nf_file, 0);
+       nfsd4_send_cb_offload(copy);
        return 0;
 }
 
@@ -2182,6 +2184,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                memcpy(&result->cb_stateid, &copy->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->attr_update = true;
                memcpy(async_copy->cp_cb_offload.co_referring_sessionid.data,
                       cstate->session->se_sessionid.data,
                       NFS4_MAX_SESSIONID_LEN);
@@ -2200,6 +2205,10 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        } else {
                status = nfsd4_do_copy(copy, copy->nf_src->nf_file,
                                       copy->nf_dst->nf_file, true);
+               if ((READ_ONCE(copy->nf_dst->nf_file->f_mode) &
+                              FMODE_NOCMTIME) != 0 &&
+                               copy->cp_res.wr_bytes_written > 0)
+                       nfsd_update_cmtime_attr(copy->nf_dst->nf_file, 0);
        }
 out:
        trace_nfsd_copy_done(copy, status);
index 417e9ad9fbb3977afbe118379282e29d7baf1cbc..9a4124c77e049d0a8c86cadc66345b7cc31bdc91 100644 (file)
@@ -752,6 +752,7 @@ struct nfsd4_copy {
 
        struct nfsd_file        *nf_src;
        struct nfsd_file        *nf_dst;
+       bool                    attr_update;
 
        copy_stateid_t          cp_stateid;