Skip to content

Commit 7663e96

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: track original timestamps in nfs4_delegation
As Trond points out [1], the "original time" mentioned in RFC 9754 refers to the timestamps on the files at the time that the delegation was granted, and not the current timestamp of the file on the server. Store the current timestamps for the file in the nfs4_delegation when granting one. Add STATX_ATIME and STATX_MTIME to the request mask in nfs4_delegation_stat(). When granting OPEN_DELEGATE_READ_ATTRS_DELEG, do a nfs4_delegation_stat() and save the correct atime. If the stat() fails for any reason, fall back to granting a normal read deleg. [1]: https://lore.kernel.org/linux-nfs/47a4e40310e797f21b5137e847b06bb203d99e66.camel@kernel.org/ Fixes: 7e13f4f ("nfsd: handle delegated timestamps in SETATTR") Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent c066ff5 commit 7663e96

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

fs/nfsd/nfs4state.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6157,7 +6157,8 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,
61576157
path.dentry = file_dentry(nf->nf_file);
61586158

61596159
rc = vfs_getattr(&path, stat,
6160-
(STATX_MODE | STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE),
6160+
STATX_MODE | STATX_SIZE | STATX_ATIME |
6161+
STATX_MTIME | STATX_CTIME | STATX_CHANGE_COOKIE,
61616162
AT_STATX_SYNC_AS_STAT);
61626163

61636164
nfsd_file_put(nf);
@@ -6274,10 +6275,14 @@ nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open,
62746275
OPEN_DELEGATE_WRITE;
62756276
dp->dl_cb_fattr.ncf_cur_fsize = stat.size;
62766277
dp->dl_cb_fattr.ncf_initial_cinfo = nfsd4_change_attribute(&stat);
6278+
dp->dl_atime = stat.atime;
6279+
dp->dl_ctime = stat.ctime;
6280+
dp->dl_mtime = stat.mtime;
62776281
trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid);
62786282
} else {
6279-
open->op_delegate_type = deleg_ts ? OPEN_DELEGATE_READ_ATTRS_DELEG :
6280-
OPEN_DELEGATE_READ;
6283+
open->op_delegate_type = deleg_ts && nfs4_delegation_stat(dp, currentfh, &stat) ?
6284+
OPEN_DELEGATE_READ_ATTRS_DELEG : OPEN_DELEGATE_READ;
6285+
dp->dl_atime = stat.atime;
62816286
trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid);
62826287
}
62836288
nfs4_put_stid(&dp->dl_stid);

fs/nfsd/state.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ struct nfs4_delegation {
224224

225225
/* for CB_GETATTR */
226226
struct nfs4_cb_fattr dl_cb_fattr;
227+
228+
/* For delegated timestamps */
229+
struct timespec64 dl_atime;
230+
struct timespec64 dl_mtime;
231+
struct timespec64 dl_ctime;
227232
};
228233

229234
static inline bool deleg_is_read(u32 dl_type)

0 commit comments

Comments
 (0)