Skip to content

Commit

Permalink
nfscl: Fix setting of mtime for the NFSv4.n client
Browse files Browse the repository at this point in the history
It was reported on freebsd-fs@ that unrolling a tarball
failed to set the correct modify time if delegations
were being issued.

This patch fixes the problem.

This bug only affects NFSv4 mounts where delegations
are being issued.  Not running the nfscbd or disabling
delegations on the NFSv4 server avoids the problem.

Reported by:	Peter Much <[email protected]>
Tested by:	Peter Much <[email protected]>
MFC after:	3 days
  • Loading branch information
Rick Macklem authored and Rick Macklem committed Feb 24, 2025
1 parent 7c3c860 commit b616d99
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sys/fs/nfs/nfs_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ int nfscl_renamedeleg(vnode_t, nfsv4stateid_t *, int *, vnode_t,
nfsv4stateid_t *, int *, NFSPROC_T *);
void nfscl_reclaimnode(vnode_t);
void nfscl_newnode(vnode_t);
void nfscl_delegmodtime(vnode_t);
void nfscl_delegmodtime(struct vnode *, struct timespec *);
void nfscl_deleggetmodtime(vnode_t, struct timespec *);
int nfscl_trydelegreturn(struct nfscldeleg *, struct ucred *,
struct nfsmount *, NFSPROC_T *);
Expand Down
7 changes: 5 additions & 2 deletions sys/fs/nfsclient/nfs_clstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5174,7 +5174,7 @@ nfscl_newnode(vnode_t vp)
* to the local clock time.
*/
void
nfscl_delegmodtime(vnode_t vp)
nfscl_delegmodtime(struct vnode *vp, struct timespec *mtime)
{
struct nfsclclient *clp;
struct nfscldeleg *dp;
Expand All @@ -5198,7 +5198,10 @@ nfscl_delegmodtime(vnode_t vp)
}
dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len);
if (dp != NULL && (dp->nfsdl_flags & NFSCLDL_WRITE)) {
nanotime(&dp->nfsdl_modtime);
if (mtime != NULL)
dp->nfsdl_modtime = *mtime;
else
nanotime(&dp->nfsdl_modtime);
dp->nfsdl_flags |= NFSCLDL_MODTIMESET;
}
NFSUNLOCKCLSTATE();
Expand Down
4 changes: 3 additions & 1 deletion sys/fs/nfsclient/nfs_clvnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ nfs_setattr(struct vop_setattr_args *ap)
* Call nfscl_delegmodtime() to set the modify time
* locally, as required.
*/
nfscl_delegmodtime(vp);
nfscl_delegmodtime(vp, NULL);
} else
NFSUNLOCKNODE(np);
/*
Expand Down Expand Up @@ -1158,6 +1158,8 @@ nfs_setattr(struct vop_setattr_args *ap)
NFSUNLOCKNODE(np);
}
}
if (vap->va_mtime.tv_sec != VNOVAL && error == 0)
nfscl_delegmodtime(vp, &vap->va_mtime);
return (error);
}

Expand Down

0 comments on commit b616d99

Please sign in to comment.