git: 3540f6b4af3c - stable/13 - nfsd: Reduce callouts rate.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 23 Jan 2022 19:59:50 UTC
The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=3540f6b4af3c32ba0aa7874da8037cd8be38569e commit 3540f6b4af3c32ba0aa7874da8037cd8be38569e Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2022-01-09 18:09:29 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2022-01-23 19:57:35 +0000 nfsd: Reduce callouts rate. Before this callouts were scheduled twice a seconds even if nfsd was never used. This reduces the rate to ~1Hz and only after nfsd first started. MFC after: 2 weeks (cherry picked from commit 3455c738ac23f723dc516ce5acd02ed24ff9f5df) --- sys/fs/nfs/nfs_commonport.c | 25 ------------------------- sys/fs/nfs/nfs_commonsubs.c | 1 - sys/fs/nfs/nfs_var.h | 1 - sys/fs/nfs/nfsport.h | 6 ------ sys/fs/nfsserver/nfs_nfsdport.c | 16 +++++++++++++--- 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index 8a100749fc32..54a7e66a5baf 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -67,12 +67,10 @@ struct nfsstatsv1 nfsstatsv1; int nfs_numnfscbd = 0; int nfscl_debuglevel = 0; char nfsv4_callbackaddr[INET6_ADDRSTRLEN]; -struct callout newnfsd_callout; int nfsrv_lughashsize = 100; struct mtx nfsrv_dslock_mtx; struct nfsdevicehead nfsrv_devidhead; volatile int nfsrv_devidcnt = 0; -void (*nfsd_call_servertimer)(void) = NULL; void (*ncl_call_invalcaches)(struct vnode *) = NULL; vop_advlock_t *nfs_advlock_p = NULL; vop_reclaim_t *nfs_reclaim_p = NULL; @@ -400,27 +398,6 @@ newnfs_getcred(void) return (cred); } -/* - * Nfs timer routine - * Call the nfsd's timer function once/sec. - */ -void -newnfs_timer(void *arg) -{ - static time_t lasttime = 0; - /* - * Call the server timer, if set up. - * The argument indicates if it is the next second and therefore - * leases should be checked. - */ - if (lasttime != NFSD_MONOSEC) { - lasttime = NFSD_MONOSEC; - if (nfsd_call_servertimer != NULL) - (*nfsd_call_servertimer)(); - } - callout_reset(&newnfsd_callout, nfscl_ticks, newnfs_timer, NULL); -} - /* * Sleep for a short period of time unless errval == NFSERR_GRACE, where * the sleep should be for 5 seconds. @@ -896,7 +873,6 @@ nfscommon_modevent(module_t mod, int type, void *data) MTX_DEF); mtx_init(&nfsrv_dslock_mtx, "nfs4ds", NULL, MTX_DEF); TAILQ_INIT(&nfsrv_devidhead); - callout_init(&newnfsd_callout, 1); newnfs_init(); nfsd_call_nfscommon = nfssvc_nfscommon; loaded = 1; @@ -910,7 +886,6 @@ nfscommon_modevent(module_t mod, int type, void *data) } nfsd_call_nfscommon = NULL; - callout_drain(&newnfsd_callout); /* Clean out the name<-->id cache. */ nfsrv_cleanusergroup(); /* and get rid of the mutexes */ diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 0351111867b0..ff92095b6182 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -929,7 +929,6 @@ newnfs_init(void) * Initialize reply list and start timer */ TAILQ_INIT(&nfsd_reqq); - NFS_TIMERINIT; } /* diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 1f20c1cb76a8..8f7ae9df78e9 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -429,7 +429,6 @@ int nfs_catnap(int, int, const char *); struct nfsreferral *nfsv4root_getreferral(vnode_t, vnode_t, u_int32_t); int nfsvno_pathconf(vnode_t, int, long *, struct ucred *, NFSPROC_T *); int nfsrv_atroot(vnode_t, uint64_t *); -void newnfs_timer(void *); int nfs_supportsnfsv4acls(vnode_t); /* nfs_commonacl.c */ diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index e099cf6e46f0..8ac4bc54a5f2 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -776,12 +776,6 @@ void nfsrvd_rcv(struct socket *, void *, int); #define NFSCNHASH(c, v) #define NCHNAMLEN 9999999 -/* - * These macros are defined to initialize and set the timer routine. - */ -#define NFS_TIMERINIT \ - newnfs_timer(NULL) - /* * Handle SMP stuff: */ diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 26bd900a2a99..9d1fbfe5801a 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <fs/nfs/nfsport.h> #include <security/mac/mac_framework.h> +#include <sys/callout.h> #include <sys/filio.h> #include <sys/hash.h> #include <sys/sysctl.h> @@ -60,7 +61,6 @@ extern int nfsrv_useacl; extern int newnfs_numnfsd; extern struct mount nfsv4root_mnt; extern struct nfsrv_stablefirst nfsrv_stablefirst; -extern void (*nfsd_call_servertimer)(void); extern SVCPOOL *nfsrvd_pool; extern struct nfsv4lock nfsd_suspend_lock; extern struct nfsclienthashhead *nfsclienthash; @@ -97,6 +97,7 @@ static char nfsd_master_comm[MAXCOMLEN + 1]; static struct timeval nfsd_master_start; static uint32_t nfsv4_sysid = 0; static fhandle_t zerofh; +struct callout nfsd_callout; static int nfssvc_srvcall(struct thread *, struct nfssvc_args *, struct ucred *); @@ -3532,6 +3533,14 @@ nfsd_mntinit(void) nfsv4root_mnt.mnt_lazyvnodelistsize = 0; } +static void +nfsd_timer(void *arg) +{ + + nfsrv_servertimer(); + callout_reset_sbt(&nfsd_callout, SBT_1S, SBT_1S, nfsd_timer, NULL, 0); +} + /* * Get a vnode for a file handle, without checking exports, etc. */ @@ -3773,6 +3782,7 @@ nfssvc_nfsd(struct thread *td, struct nfssvc_args *uap) nfsdarg.mdspathlen = 0; nfsdarg.mirrorcnt = 1; } + nfsd_timer(NULL); error = nfsrvd_nfsd(td, &nfsdarg); free(nfsdarg.addr, M_TEMP); free(nfsdarg.dnshost, M_TEMP); @@ -6818,6 +6828,7 @@ nfsd_modevent(module_t mod, int type, void *data) mtx_init(&nfsrv_dontlistlock_mtx, "nfs4dnl", NULL, MTX_DEF); mtx_init(&nfsrv_recalllock_mtx, "nfs4rec", NULL, MTX_DEF); lockinit(&nfsv4root_mnt.mnt_explock, PVFS, "explock", 0, 0); + callout_init(&nfsd_callout, 1); nfsrvd_initcache(); nfsd_init(); NFSD_LOCK(); @@ -6828,7 +6839,6 @@ nfsd_modevent(module_t mod, int type, void *data) vn_deleg_ops.vndeleg_recall = nfsd_recalldelegation; vn_deleg_ops.vndeleg_disable = nfsd_disabledelegation; #endif - nfsd_call_servertimer = nfsrv_servertimer; nfsd_call_nfsd = nfssvc_nfsd; loaded = 1; break; @@ -6843,8 +6853,8 @@ nfsd_modevent(module_t mod, int type, void *data) vn_deleg_ops.vndeleg_recall = NULL; vn_deleg_ops.vndeleg_disable = NULL; #endif - nfsd_call_servertimer = NULL; nfsd_call_nfsd = NULL; + callout_drain(&nfsd_callout); /* Clean out all NFSv4 state. */ nfsrv_throwawayallstate(curthread);