Skip to contentSkip to conversation

nfsd update mtime/ctime on CLONE/COPY with delegated attritutes

PATCH In review Olga Kornievskaia 2 participants 4 messages Apr 10

Subsystems (2)
lore
Share & tools
lore

Olga Kornievskaia

author reviewer
#0 lore raw

v4 cover nfsd update mtime/ctime on CLONE/COPY with delegated attritutes

generic/407 is failing in presence of delegated attributes and this patch series explores the solution where the CLONE compound returns updated mtime/ctime in the GETATTR op in the compound.

Both CLONE and COPY need to update destination file mtime/ctime (in presence of delegated timestamp) when file was modified.

v4 changes:
patch1: moved struct iattr into nfsd_update_cmtime_attr() which now moved into nfs4state.c and takes flags as 2nd arg for adding ATTR_ATIME when needed.
patch2: removed comment about dput in nfsd4_do_async_copy() and now testing for a set nfsd4_copy->attr_update which is set if file had NOCMTIME set on open then timestamps are modified.

v3 changes:
--- Consolidated synchronous and asynchronous COPY patches into single patch.
patch1: pulled out notify_change() code from nfsd4_finalize_deleg_timestamps as it's shared with nfsd_update_cmtime_attr and both paths log an error if notify_change() fails
patch2: dentry can be pulled from copy->nf_dst->nf_file.fh_path.dentry and no longer requires additional tracking.

Olga Kornievskaia (2):
nfsd: update mtime/ctime on CLONE in presense of delegated attributes
nfsd: update mtime/ctime on COPY in presence of delegated attributes

 fs/nfsd/nfs4proc.c  | 14 +++++++++++++-
 fs/nfsd/nfs4state.c | 44 +++++++++++++++++++++++++++++---------------
 fs/nfsd/state.h     |  1 +
 fs/nfsd/xdr4.h      |  1 +
 4 files changed, 44 insertions(+), 16 deletions(-)
Signature · 1 line
2.52.0
author reviewer
#1 lore raw

PATCH v4 1/2 nfsd: update mtime/ctime on CLONE in presense of delegated attributes

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 CLONE 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")
---
 fs/nfsd/nfs4proc.c  |  3 +++
 fs/nfsd/nfs4state.c | 44 +++++++++++++++++++++++++++++---------------
 fs/nfsd/state.h     |  1 +
 3 files changed, 33 insertions(+), 15 deletions(-)
fs/nfsd/nfs4proc.c +3 -0
index 6880c5c520e7..ffe85b21a9ac 100644
@@ -1413,6 +1413,9 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 			dst, clone->cl_dst_pos, clone->cl_count,
 			EX_ISSYNC(cstate->current_fh.fh_export));
 
+	if (!status && (READ_ONCE(dst->nf_file->f_mode) & FMODE_NOCMTIME) != 0)
+		nfsd_update_cmtime_attr(dst->nf_file, 0);
+
 	nfsd_file_put(dst);
 	nfsd_file_put(src);
 out:
fs/nfsd/nfs4state.c +29 -15

59 lines not on this page · raw message

fs/nfsd/state.h +1 -0
index 6fcbf1e427d4..4cd35092b899 100644
@@ -825,6 +825,7 @@ extern void nfsd4_shutdown_copy(struct nfs4_client *clp);
 void nfsd4_put_client(struct nfs4_client *clp);
 void nfsd4_async_copy_reaper(struct nfsd_net *nn);
 bool nfsd4_has_active_async_copies(struct nfs4_client *clp);
+void nfsd_update_cmtime_attr(struct file *f, unsigned int flags);
 extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name,
 				struct xdr_netobj princhash, struct nfsd_net *nn);
 extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn);
Signature · 1 line
2.52.0
author reviewer
#2 lore raw

PATCH v4 2/2 nfsd: update mtime/ctime on COPY in presence of delegated attributes

In reply to Olga Kornievskaia

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")
---
 fs/nfsd/nfs4proc.c | 11 ++++++++++-
 fs/nfsd/xdr4.h     |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)
fs/nfsd/nfs4proc.c +10 -1
index ffe85b21a9ac..850a0b31c057 100644
@@ -2121,8 +2121,10 @@ static int nfsd4_do_async_copy(void *data)
 
 	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);
fs/nfsd/xdr4.h +1 -0
index 417e9ad9fbb3..9a4124c77e04 100644
@@ -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;
 
Signature · 1 line
2.52.0
maintainer
#3 lore raw
In reply to Olga Kornievskaia

From: Chuck Lever <[email protected]>

Quoted 8 lines · Olga Kornievskaia

generic/407 is failing in presence of delegated attributes and this patch series explores the solution where the CLONE compound returns updated mtime/ctime in the GETATTR op in the compound.

Both CLONE and COPY need to update destination file mtime/ctime (in presence of delegated timestamp) when file was modified.

[...]

Applied to nfsd-testing, thanks!

[1/2] nfsd: update mtime/ctime on CLONE in presense of delegated attributes

      commit: a7f570141bae209189f05fdff295f67fe84dd183
[2/2] nfsd: update mtime/ctime on COPY in presence of delegated attributes
      commit: d0814470307048890b3cf6c8b373815f0b8cd64d

--
Chuck Lever