From nobody Sun Jan 23 19:59:50 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 949B119838E7; Sun, 23 Jan 2022 19:59:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JhkVH0638z4Z2W; Sun, 23 Jan 2022 19:59:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642967991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=423Yk971g5Nq1sxwWe+6C70xXC8kubKfMB7cjSLtPBc=; b=rFRrhjod7BlTj40dGwEsk2s6oEWW876kvuKR66creq9FnVhQqk8QKPUkOO5g4jwFGnsKEv jWuVVuuF55kpAgAUL9H4F4nl+lJYsUBZAvHBvIyta7DrFhGOYjqF2AZpWSYt+efXUZzUVE 2Ua46sggQw2zVLpVjqJdSbSzjFDGii4h95GcSD7Zk6e+8GaLK+thB0DnjYV2zyRxe5jeQl PIPfhGgIiV6XgDw3K3OtzPi/V1urMqsc4HHT9oZg+A/ZGFy65qMPz40lie2hZCWYHACB3P oUZvIYwQQLM++Rox8gQpSc23zd05WpDtWpNtaikQy6GTL/tCHIEzYx30aHs4NA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B31763F4; Sun, 23 Jan 2022 19:59:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20NJxorc064163; Sun, 23 Jan 2022 19:59:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20NJxo8N064162; Sun, 23 Jan 2022 19:59:50 GMT (envelope-from git) Date: Sun, 23 Jan 2022 19:59:50 GMT Message-Id: <202201231959.20NJxo8N064162@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 3540f6b4af3c - stable/13 - nfsd: Reduce callouts rate. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3540f6b4af3c32ba0aa7874da8037cd8be38569e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642967991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=423Yk971g5Nq1sxwWe+6C70xXC8kubKfMB7cjSLtPBc=; b=cmVcBPcED8KWx6OiRwgqTns9TmSSqGYVadaPhxDGRBPKX/3IV4D5wImS8G1NHge+ef5Qn1 jI7YAWKX4XGY6dmhSL822crWKVDQlUxswU1rcy4yzo6f8ft8P/BkdkA82bYAl7HtR4NZHb u8YW1Ez1FkgQ5NK1qjZ1NJRV4ovoSnj0yIdBwCWDL40gi/rUy6sS4F9F6mJjOB9CJ6cIVu u8jgP358MmU9KioVHzApjq/2ja9LJayMlBWBm1uKQYldSh4tYgrAQistxzxvQ4mh9Os4VY gkOPT7oEsfWwOAIe4J/2igaHwCtRcY19XG/UGg2MKWx4Jveg+pUuueQ303rJcw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642967991; a=rsa-sha256; cv=none; b=s0Eovzp30uYSQQjSjI4PsEPuJO8jIFNNbd2r39B+Wa0YGI2ofZHyzPoQN5cNS1GPRTPONz siG5yHjDUDCQQ5zKZa/W+b6hkvyY1MD28XviuetvoAXdzraw6yryWvZKvZWyF4wqRHtVWi cRPbenh61HKnSndKKwKVh2ubEANmP7uKa6qjkKKn3Gy5Vije4npDoHaqIxcO1etgQn373o INAVuVh+bEUccD5ip0F6/BWXuCaGgL7Gg/NIEcr5ZMOZRhHl6N+b2qtFjwYef1l1kDAND5 yDFnNb3TOZAdsXjewsiy1ZHrAXzKnWqO1AiSkJiR3q1ES2vI+AYc3nsVP1r81A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=3540f6b4af3c32ba0aa7874da8037cd8be38569e commit 3540f6b4af3c32ba0aa7874da8037cd8be38569e Author: Alexander Motin AuthorDate: 2022-01-09 18:09:29 +0000 Commit: Alexander Motin 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 #include +#include #include #include #include @@ -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);