diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2019-01-19 01:53:45 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2019-01-19 01:53:45 +0000 |
commit | 15b875d2b645610a3a9a7a24dde2aeb83a3bf24f (patch) | |
tree | 315ebd7335ec646d342342fe20d740f8b0fb439c /sys/nfs/nfs_serv.c | |
parent | a0997ced0a090ed5a40a85cbafa95fc8471831e7 (diff) |
Move boottime into the timehands.
To protect the timehands we first need to protect the basis for all UTC
time in the kernel: the boottime.
Because the boottime can be changed at any time it needs to be versioned
along with the other members of the timehands to enable safe lockless reads
when using it for anything. So the global boottime timespec goes away and
the static boottimebin becomes a member of the timehands. Instead of reading
the global boottime you use one of two interfaces: binboottime(9) or
microboottime(9). nanoboottime(9) can trivially be added later, though there
are no consumers for it at the moment.
This introduces one small change in behavior. We used to advance the
reported boottime just before launching kernel threads from main().
This makes it look to userland like we "booted" moments before those
threads were launched. Because there is no longer a boottime global we
can no longer trivially do this from main(), so the boottime we report
to userspace via e.g. kern.boottime will now reflect whatever the time
was when we bootstrapped the timehands via inittodr(9). This is usually
no more than a minute before the kernel threads are launched from main().
The prior behavior can be restored by adding a new interface to the
timecounter layer in a future commit.
Based on FreeBSD r303387.
Discussed with mpi@ and visa@.
ok visa@
Diffstat (limited to 'sys/nfs/nfs_serv.c')
-rw-r--r-- | sys/nfs/nfs_serv.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index f69afb57f98..44dbfdc4a6c 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.118 2019/01/18 13:56:38 bluhm Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.119 2019/01/19 01:53:44 cheloha Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -685,6 +685,7 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, int i, cnt; struct mbuf *mp; struct nfs_fattr *fp; + struct timeval boottime; struct vattr va, forat; u_int32_t *tl; int32_t t1; @@ -829,8 +830,9 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, * but it may make the values more human readable, * for debugging purposes. */ + microboottime(&boottime); *tl++ = txdr_unsigned(boottime.tv_sec); - *tl = txdr_unsigned(boottime.tv_nsec/1000); + *tl = txdr_unsigned(boottime.tv_usec); } else { fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); @@ -2506,6 +2508,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct vattr bfor, aft; struct vnode *vp; struct nfsm_info info; + struct timeval boottime; nfsfh_t nfh; fhandle_t *fhp; u_int32_t *tl; @@ -2548,8 +2551,9 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsm_srvwcc(nfsd, for_ret, &bfor, aft_ret, &aft, &info); if (!error) { tl = nfsm_build(&info.nmi_mb, NFSX_V3WRITEVERF); + microboottime(&boottime); *tl++ = txdr_unsigned(boottime.tv_sec); - *tl = txdr_unsigned(boottime.tv_nsec/1000); + *tl = txdr_unsigned(boottime.tv_usec); } else error = 0; nfsmout: |