Skip to content

Commit c066ff5

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: use ATTR_CTIME_SET for delegated ctime updates
Ensure that notify_change() doesn't clobber a delegated ctime update with current_time() by setting ATTR_CTIME_SET for those updates. Don't bother setting the timestamps in cb_getattr_update_times() in the non-delegated case. notify_change() will do that itself. 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 afc5b36 commit c066ff5

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

fs/nfsd/nfs4state.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9167,14 +9167,14 @@ static bool set_cb_time(struct timespec64 *cb, const struct timespec64 *orig,
91679167
static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation *dp)
91689168
{
91699169
struct inode *inode = d_inode(dentry);
9170-
struct timespec64 now = current_time(inode);
91719170
struct nfs4_cb_fattr *ncf = &dp->dl_cb_fattr;
91729171
struct iattr attrs = { };
91739172
int ret;
91749173

91759174
if (deleg_attrs_deleg(dp->dl_type)) {
91769175
struct timespec64 atime = inode_get_atime(inode);
91779176
struct timespec64 mtime = inode_get_mtime(inode);
9177+
struct timespec64 now = current_time(inode);
91789178

91799179
attrs.ia_atime = ncf->ncf_cb_atime;
91809180
attrs.ia_mtime = ncf->ncf_cb_mtime;
@@ -9183,12 +9183,12 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation
91839183
attrs.ia_valid |= ATTR_ATIME | ATTR_ATIME_SET;
91849184

91859185
if (set_cb_time(&attrs.ia_mtime, &mtime, &now)) {
9186-
attrs.ia_valid |= ATTR_CTIME | ATTR_MTIME | ATTR_MTIME_SET;
9186+
attrs.ia_valid |= ATTR_CTIME | ATTR_CTIME_SET |
9187+
ATTR_MTIME | ATTR_MTIME_SET;
91879188
attrs.ia_ctime = attrs.ia_mtime;
91889189
}
91899190
} else {
91909191
attrs.ia_valid |= ATTR_MTIME | ATTR_CTIME;
9191-
attrs.ia_mtime = attrs.ia_ctime = now;
91929192
}
91939193

91949194
if (!attrs.ia_valid)

fs/nfsd/nfs4xdr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ nfsd4_decode_fattr4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen,
539539
iattr->ia_mtime.tv_nsec = modify.nseconds;
540540
iattr->ia_ctime.tv_sec = modify.seconds;
541541
iattr->ia_ctime.tv_nsec = modify.nseconds;
542-
iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME | ATTR_MTIME_SET | ATTR_DELEG;
542+
iattr->ia_valid |= ATTR_CTIME | ATTR_CTIME_SET |
543+
ATTR_MTIME | ATTR_MTIME_SET | ATTR_DELEG;
543544
}
544545

545546
/* request sanity: did attrlist4 contain the expected number of words? */

0 commit comments

Comments
 (0)