nfsd update mtime/ctime on CLONE/COPY with delegated attritutes
Subsystems (2)
Olga Kornievskaia
reviewerv4 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
Olga Kornievskaia
reviewerPATCH 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.
--- 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
@@ -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
@@ -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
Olga Kornievskaia
reviewerPATCH v4 2/2 nfsd: update mtime/ctime on COPY in presence of delegated attributes
In reply to Olga KornievskaiaWhen 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.
--- fs/nfsd/nfs4proc.c | 11 ++++++++++- fs/nfsd/xdr4.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)
fs/nfsd/nfs4proc.c +10 -1
@@ -2121,8 +2121,10 @@ 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); +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, ©->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
@@ -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
Chuck Lever
maintainerFrom: 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