diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2009-01-24 23:35:48 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2009-01-24 23:35:48 +0000 |
commit | 00ffba6864dfeeb773caff98381adfaa9b6f7822 (patch) | |
tree | 8086d06c935b6aaa4cd8a7f8282024d0788307bd | |
parent | 86832ad61e0ff002c49152ecaf00eb1aa87d21bb (diff) |
Use a timespec for the server write deadline and procrastination
timeouts. Rrids us of the ugly cur_sec variable, and some shadows.
Also helps with granularity.
Diff from blambert@ who asked me to commit this since he's away for
some days and we wanted to put this in with the timespec changes in
the nfsnode.
-rw-r--r-- | sys/nfs/nfs.h | 4 | ||||
-rw-r--r-- | sys/nfs/nfs_serv.c | 21 | ||||
-rw-r--r-- | sys/nfs/nfs_socket.c | 6 | ||||
-rw-r--r-- | sys/nfs/nfs_syscalls.c | 11 |
4 files changed, 20 insertions, 22 deletions
diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h index d1f12d525de..33eb2a5605d 100644 --- a/sys/nfs/nfs.h +++ b/sys/nfs/nfs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs.h,v 1.37 2009/01/24 23:25:17 thib Exp $ */ +/* $OpenBSD: nfs.h,v 1.38 2009/01/24 23:35:47 thib Exp $ */ /* $NetBSD: nfs.h,v 1.10.4.1 1996/05/27 11:23:56 fvdl Exp $ */ /* @@ -335,7 +335,7 @@ struct nfsd { * Some fields are used only when write request gathering is performed. */ struct nfsrv_descript { - u_quad_t nd_time; /* Write deadline (usec) */ + struct timeval nd_time; /* Write deadline */ off_t nd_off; /* Start byte offset */ off_t nd_eoff; /* and end byte offset */ LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 5d2608020d3..62e64c8cc17 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.61 2009/01/18 13:54:27 thib Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.62 2009/01/24 23:35:47 thib Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -89,6 +89,10 @@ extern struct nfsstats nfsstats; extern nfstype nfsv2_type[9]; extern nfstype nfsv3_type[9]; int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000; +struct timeval nfsrvw_procrastinate_tv = { + (NFS_GATHERDELAY * 1000) / 1000000, /* tv_sec */ + (NFS_GATHERDELAY * 1000) % 1000000 /* tv_usec */ +}; /* * nfs v3 access service @@ -877,7 +881,6 @@ nfsrv_writegather(ndp, slp, procp, mrq) struct mbuf *mb, *mreq, *mrep, *md; struct vnode *vp; struct uio io, *uiop = &io; - u_quad_t cur_usec; struct timeval tv; *mrq = NULL; @@ -893,8 +896,7 @@ nfsrv_writegather(ndp, slp, procp, mrq) nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; getmicrotime(&tv); - cur_usec = (u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec; - nfsd->nd_time = cur_usec + nfsrvw_procrastinate; + timeradd(&nfsd->nd_time, &nfsrvw_procrastinate_tv, &nfsd->nd_time); /* * Now, get the write header.. @@ -949,7 +951,7 @@ nfsmout: nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb); nfsd->nd_mreq = mreq; nfsd->nd_mrep = NULL; - nfsd->nd_time = 0; + timerclear(&nfsd->nd_time); } /* @@ -958,7 +960,7 @@ nfsmout: s = splsoftclock(); owp = NULL; wp = LIST_FIRST(&slp->ns_tq); - while (wp && wp->nd_time < nfsd->nd_time) { + while (wp && timercmp(&wp->nd_time, &nfsd->nd_time, <)) { owp = wp; wp = LIST_NEXT(wp, nd_tq); } @@ -1006,11 +1008,10 @@ nfsmout: */ loop1: getmicrotime(&tv); - cur_usec = (u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec; s = splsoftclock(); for (nfsd = LIST_FIRST(&slp->ns_tq); nfsd != NULL; nfsd = owp) { owp = LIST_NEXT(nfsd, nd_tq); - if (nfsd->nd_time > cur_usec) + if (timercmp(&nfsd->nd_time, &tv, >)) break; if (nfsd->nd_mreq) continue; @@ -1126,7 +1127,7 @@ loop1: */ s = splsoftclock(); if (nfsd != swp) { - nfsd->nd_time = 0; + timerclear(&nfsd->nd_time); LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); } nfsd = LIST_FIRST(&swp->nd_coalesce); @@ -1136,7 +1137,7 @@ loop1: splx(s); } while (nfsd); s = splsoftclock(); - swp->nd_time = 0; + timerclear(&swp->nd_time); LIST_INSERT_HEAD(&slp->ns_tq, swp, nd_tq); splx(s); goto loop1; diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index efa72fa7830..8fef3976f97 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.76 2009/01/24 11:40:06 thib Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.77 2009/01/24 23:35:47 thib Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -1149,7 +1149,6 @@ nfs_timer(arg) #ifdef NFSSERVER struct nfssvc_sock *slp; struct timeval tv; - u_quad_t cur_usec; #endif s = splsoftnet(); @@ -1244,10 +1243,9 @@ nfs_timer(arg) * completed now. */ getmicrotime(&tv); - cur_usec = (u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec; TAILQ_FOREACH(slp, &nfssvc_sockhead, ns_chain) { if (LIST_FIRST(&slp->ns_tq) && - LIST_FIRST(&slp->ns_tq)->nd_time <= cur_usec) + timercmp(&LIST_FIRST(&slp->ns_tq)->nd_time, &tv, <=)) nfsrv_wakenfsd(slp); } #endif /* NFSSERVER */ diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 3235878f0b0..283a093b85d 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_syscalls.c,v 1.74 2009/01/18 21:04:41 blambert Exp $ */ +/* $OpenBSD: nfs_syscalls.c,v 1.75 2009/01/24 23:35:47 thib Exp $ */ /* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */ /* @@ -78,6 +78,7 @@ extern int nfs_numasync; extern int nfsrtton; extern struct nfsstats nfsstats; extern int nfsrvw_procrastinate; +extern struct timeval nfsrvw_procrastinate_tv; struct nfssvc_sock *nfs_udpsock; int nfsd_waiting = 0; @@ -356,8 +357,6 @@ nfssvc_nfsd(nsd, argp, p) if ((slp = nfsd->nfsd_slp) == (struct nfssvc_sock *)0) continue; if (slp->ns_flag & SLP_VALID) { - struct timeval tv; - if (slp->ns_flag & SLP_DISCONN) nfsrv_zapsock(slp); else if (slp->ns_flag & SLP_NEEDQ) { @@ -373,8 +372,8 @@ nfssvc_nfsd(nsd, argp, p) cur_usec = (u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec; if (error && LIST_FIRST(&slp->ns_tq) && - LIST_FIRST(&slp->ns_tq)->nd_time - <= cur_usec) { + timercmp(&LIST_FIRST(&slp->ns_tq)->nd_time, + &tv, <=)) { error = 0; cacherep = RC_DOIT; writes_todo = 1; @@ -515,7 +514,7 @@ nfssvc_nfsd(nsd, argp, p) (u_quad_t)tv.tv_usec; s = splsoftclock(); if (LIST_FIRST(&slp->ns_tq) && - LIST_FIRST(&slp->ns_tq)->nd_time <= cur_usec) { + timercmp(&LIST_FIRST(&slp->ns_tq)->nd_time, &tv, <=)) { cacherep = RC_DOIT; writes_todo = 1; } else |