diff options
author | jhb <jhb@FreeBSD.org> | 2013-01-18 18:43:38 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2013-01-18 18:43:38 +0000 |
commit | 812f7427ff704698be35b66b5ddb9182d7d6d22e (patch) | |
tree | 175077f108ffeadc6414dccb1f19dad26b197ecf | |
parent | a757b0e056a396f4f674631a6e5eea6d29ed1087 (diff) | |
download | FreeBSD-src-812f7427ff704698be35b66b5ddb9182d7d6d22e.zip FreeBSD-src-812f7427ff704698be35b66b5ddb9182d7d6d22e.tar.gz |
Use vfs_timestamp() to set file timestamps rather than invoking
getmicrotime() or getnanotime() directly in NFS.
Reviewed by: rmacklem, bde
MFC after: 1 week
-rw-r--r-- | sys/fs/nfsclient/nfs_clvnops.c | 6 | ||||
-rw-r--r-- | sys/fs/nfsserver/nfs_nfsdport.c | 20 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vnops.c | 6 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsubs.c | 4 |
4 files changed, 13 insertions, 23 deletions
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 3a898f2..f778009 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3247,7 +3247,7 @@ nfsfifo_read(struct vop_read_args *ap) */ mtx_lock(&np->n_mtx); np->n_flag |= NACC; - getnanotime(&np->n_atim); + vfs_timestamp(&np->n_atim); mtx_unlock(&np->n_mtx); error = fifo_specops.vop_read(ap); return error; @@ -3266,7 +3266,7 @@ nfsfifo_write(struct vop_write_args *ap) */ mtx_lock(&np->n_mtx); np->n_flag |= NUPD; - getnanotime(&np->n_mtim); + vfs_timestamp(&np->n_mtim); mtx_unlock(&np->n_mtx); return(fifo_specops.vop_write(ap)); } @@ -3286,7 +3286,7 @@ nfsfifo_close(struct vop_close_args *ap) mtx_lock(&np->n_mtx); if (np->n_flag & (NACC | NUPD)) { - getnanotime(&ts); + vfs_timestamp(&ts); if (np->n_flag & NACC) np->n_atim = ts; if (np->n_flag & NUPD) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index f56a292..1731c72 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1476,7 +1476,7 @@ nfsvno_updfilerev(struct vnode *vp, struct nfsvattr *nvap, struct vattr va; VATTR_NULL(&va); - getnanotime(&va.va_mtime); + vfs_timestamp(&va.va_mtime); (void) VOP_SETATTR(vp, &va, cred); (void) nfsvno_getattr(vp, nvap, cred, p, 1); } @@ -2248,7 +2248,6 @@ nfsrv_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, { u_int32_t *tl; struct nfsv2_sattr *sp; - struct timeval curtime; int error = 0, toclient = 0; switch (nd->nd_flag & (ND_NFSV2 | ND_NFSV3 | ND_NFSV4)) { @@ -2307,9 +2306,7 @@ nfsrv_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, toclient = 1; break; case NFSV3SATTRTIME_TOSERVER: - NFSGETTIME(&curtime); - nvap->na_atime.tv_sec = curtime.tv_sec; - nvap->na_atime.tv_nsec = curtime.tv_usec * 1000; + vfs_timestamp(&nvap->na_atime); nvap->na_vaflags |= VA_UTIMES_NULL; break; }; @@ -2321,9 +2318,7 @@ nfsrv_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, nvap->na_vaflags &= ~VA_UTIMES_NULL; break; case NFSV3SATTRTIME_TOSERVER: - NFSGETTIME(&curtime); - nvap->na_mtime.tv_sec = curtime.tv_sec; - nvap->na_mtime.tv_nsec = curtime.tv_usec * 1000; + vfs_timestamp(&nvap->na_mtime); if (!toclient) nvap->na_vaflags |= VA_UTIMES_NULL; break; @@ -2353,7 +2348,6 @@ nfsv4_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, u_char *cp, namestr[NFSV4_SMALLSTR + 1]; uid_t uid; gid_t gid; - struct timeval curtime; error = nfsrv_getattrbits(nd, attrbitp, NULL, &retnotsup); if (error) @@ -2488,9 +2482,7 @@ nfsv4_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, toclient = 1; attrsum += NFSX_V4TIME; } else { - NFSGETTIME(&curtime); - nvap->na_atime.tv_sec = curtime.tv_sec; - nvap->na_atime.tv_nsec = curtime.tv_usec * 1000; + vfs_timestamp(&nvap->na_atime); nvap->na_vaflags |= VA_UTIMES_NULL; } break; @@ -2515,9 +2507,7 @@ nfsv4_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, nvap->na_vaflags &= ~VA_UTIMES_NULL; attrsum += NFSX_V4TIME; } else { - NFSGETTIME(&curtime); - nvap->na_mtime.tv_sec = curtime.tv_sec; - nvap->na_mtime.tv_nsec = curtime.tv_usec * 1000; + vfs_timestamp(&nvap->na_mtime); if (!toclient) nvap->na_vaflags |= VA_UTIMES_NULL; } diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index ca9edad..5026daf 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -3458,7 +3458,7 @@ nfsfifo_read(struct vop_read_args *ap) */ mtx_lock(&np->n_mtx); np->n_flag |= NACC; - getnanotime(&np->n_atim); + vfs_timestamp(&np->n_atim); mtx_unlock(&np->n_mtx); error = fifo_specops.vop_read(ap); return error; @@ -3477,7 +3477,7 @@ nfsfifo_write(struct vop_write_args *ap) */ mtx_lock(&np->n_mtx); np->n_flag |= NUPD; - getnanotime(&np->n_mtim); + vfs_timestamp(&np->n_mtim); mtx_unlock(&np->n_mtx); return(fifo_specops.vop_write(ap)); } @@ -3497,7 +3497,7 @@ nfsfifo_close(struct vop_close_args *ap) mtx_lock(&np->n_mtx); if (np->n_flag & (NACC | NUPD)) { - getnanotime(&ts); + vfs_timestamp(&ts); if (np->n_flag & NACC) np->n_atim = ts; if (np->n_flag & NUPD) diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index eedac6c..04371da 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -1393,7 +1393,7 @@ nfsm_srvsattr_xx(struct vattr *a, struct mbuf **md, caddr_t *dpos) toclient = 1; break; case NFSV3SATTRTIME_TOSERVER: - getnanotime(&(a)->va_atime); + vfs_timestamp(&a->va_atime); a->va_vaflags |= VA_UTIMES_NULL; break; } @@ -1409,7 +1409,7 @@ nfsm_srvsattr_xx(struct vattr *a, struct mbuf **md, caddr_t *dpos) a->va_vaflags &= ~VA_UTIMES_NULL; break; case NFSV3SATTRTIME_TOSERVER: - getnanotime(&(a)->va_mtime); + vfs_timestamp(&a->va_mtime); if (toclient == 0) a->va_vaflags |= VA_UTIMES_NULL; break; |