only do nfs rpc callouts if there is work to do.

Submitted by:	kan
Approved by:	alfred
This commit is contained in:
rees 2004-03-25 21:48:09 +00:00
parent 75ae6199e5
commit 4bf96c35a5
4 changed files with 14 additions and 11 deletions

View File

@ -136,7 +136,7 @@ MALLOC_DECLARE(M_NFSHASH);
extern struct uma_zone *nfsmount_zone; extern struct uma_zone *nfsmount_zone;
extern struct callout_handle nfs_timer_handle; extern struct callout nfs_callout;
extern struct nfsstats nfsstats; extern struct nfsstats nfsstats;
extern int nfs_numasync; extern int nfs_numasync;

View File

@ -140,7 +140,7 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "");
#define NFS_MAXCWND (NFS_CWNDSCALE * 32) #define NFS_MAXCWND (NFS_CWNDSCALE * 32)
#define NFS_NBACKOFF 8 #define NFS_NBACKOFF 8
static int nfs_backoff[NFS_NBACKOFF] = { 2, 4, 8, 16, 32, 64, 128, 256, }; static int nfs_backoff[NFS_NBACKOFF] = { 2, 4, 8, 16, 32, 64, 128, 256, };
struct callout_handle nfs_timer_handle; struct callout nfs_callout;
static int nfs_msg(struct thread *, char *, char *); static int nfs_msg(struct thread *, char *, char *);
static int nfs_rcvlock(struct nfsreq *); static int nfs_rcvlock(struct nfsreq *);
@ -938,6 +938,8 @@ tryagain:
* to put it LAST so timer finds oldest requests first. * to put it LAST so timer finds oldest requests first.
*/ */
s = splsoftclock(); s = splsoftclock();
if (TAILQ_EMPTY(&nfs_reqq))
callout_reset(&nfs_callout, nfs_ticks, nfs_timer, NULL);
TAILQ_INSERT_TAIL(&nfs_reqq, rep, r_chain); TAILQ_INSERT_TAIL(&nfs_reqq, rep, r_chain);
/* /*
@ -977,6 +979,8 @@ tryagain:
*/ */
s = splsoftclock(); s = splsoftclock();
TAILQ_REMOVE(&nfs_reqq, rep, r_chain); TAILQ_REMOVE(&nfs_reqq, rep, r_chain);
if (TAILQ_EMPTY(&nfs_reqq))
callout_stop(&nfs_callout);
splx(s); splx(s);
/* /*
@ -1184,7 +1188,6 @@ nfs_timer(void *arg)
} }
} }
splx(s); splx(s);
nfs_timer_handle = timeout(nfs_timer, NULL, nfs_ticks);
} }
/* /*

View File

@ -418,8 +418,7 @@ nfs_init(struct vfsconf *vfsp)
* Initialize reply list and start timer * Initialize reply list and start timer
*/ */
TAILQ_INIT(&nfs_reqq); TAILQ_INIT(&nfs_reqq);
callout_init(&nfs_callout, 0);
nfs_timer(0);
nfs_prev_nfsclnt_sy_narg = sysent[SYS_nfsclnt].sy_narg; nfs_prev_nfsclnt_sy_narg = sysent[SYS_nfsclnt].sy_narg;
sysent[SYS_nfsclnt].sy_narg = 2; sysent[SYS_nfsclnt].sy_narg = 2;
@ -435,7 +434,7 @@ int
nfs_uninit(struct vfsconf *vfsp) nfs_uninit(struct vfsconf *vfsp)
{ {
untimeout(nfs_timer, (void *)NULL, nfs_timer_handle); callout_stop(&nfs_callout);
sysent[SYS_nfsclnt].sy_narg = nfs_prev_nfsclnt_sy_narg; sysent[SYS_nfsclnt].sy_narg = nfs_prev_nfsclnt_sy_narg;
sysent[SYS_nfsclnt].sy_call = nfs_prev_nfsclnt_sy_call; sysent[SYS_nfsclnt].sy_call = nfs_prev_nfsclnt_sy_call;
return (0); return (0);

View File

@ -284,7 +284,6 @@ rpcclnt_init(void)
rpcclnt_timer(&rpcclnt_timer_to); rpcclnt_timer(&rpcclnt_timer_to);
#else /* !__OpenBSD__ */ #else /* !__OpenBSD__ */
callout_init(&rpcclnt_callout, 0); callout_init(&rpcclnt_callout, 0);
rpcclnt_timer(NULL);
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
RPCDEBUG("rpc initialed"); RPCDEBUG("rpc initialed");
@ -296,9 +295,8 @@ void
rpcclnt_uninit(void) rpcclnt_uninit(void)
{ {
RPCDEBUG("uninit"); RPCDEBUG("uninit");
callout_stop(&rpcclnt_callout);
/* XXX delete sysctl variables? */ /* XXX delete sysctl variables? */
callout_stop(&rpcclnt_callout);
} }
int int
@ -1197,6 +1195,9 @@ rpcclnt_request(rpc, mrest, procnum, td, cred, reply)
* LAST so timer finds oldest requests first. * LAST so timer finds oldest requests first.
*/ */
s = splsoftclock(); s = splsoftclock();
if (TAILQ_EMPTY(&rpctask_q))
callout_reset(&rpcclnt_callout, rpcclnt_ticks, rpcclnt_timer,
NULL);
TAILQ_INSERT_TAIL(&rpctask_q, task, r_chain); TAILQ_INSERT_TAIL(&rpctask_q, task, r_chain);
/* /*
@ -1238,6 +1239,8 @@ rpcclnt_request(rpc, mrest, procnum, td, cred, reply)
*/ */
s = splsoftclock(); s = splsoftclock();
TAILQ_REMOVE(&rpctask_q, task, r_chain); TAILQ_REMOVE(&rpctask_q, task, r_chain);
if (TAILQ_EMPTY(&rpctask_q))
callout_stop(&rpcclnt_callout);
splx(s); splx(s);
/* /*
@ -1475,8 +1478,6 @@ rpcclnt_timer(arg)
#ifdef __OpenBSD__ #ifdef __OpenBSD__
timeout_add(rpcclnt_timer, to, rpcclnt_ticks); timeout_add(rpcclnt_timer, to, rpcclnt_ticks);
#else
callout_reset(&rpcclnt_callout, rpcclnt_ticks, rpcclnt_timer, NULL);
#endif #endif
} }