From nobody Mon Feb 20 21:12:41 2023 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 4PLFVx5xp1z3sBWf; Mon, 20 Feb 2023 21:12:41 +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 4PLFVx5NtFz3krs; Mon, 20 Feb 2023 21:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676927561; 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=FT+MZzo2P/iSxgX8dwLwqLEqMI1OE/9JFkLPTYp/Il4=; b=SdnrusThhKDfJUBdOzMuCk4V08UD0ua2ztzRNEu2n1Jd5SzpL4CdaLvJUOdRkJAZCJtI7Q Cot+ES1qtrK6LWYP3iKj7jYQ+uuTOW1BJJJJCbJoFF3m5ibWlM5Si3LxC03HeyJe8XCIPy BbYu8ymb3qn/pCInBErcL0sumkF0yScthzzvGHf5DL366sB8uawF95ISUr7DIjQzapuXti WbyNmpOBIHL97uGfz9O3fXoB36KgIlekmkSXb9VFCOlFPVFN+yXGkMgaEidCJH0OmzdvGU GPbCGiGab4PllX2VqV3ddnMNb+1MLl+RmoAE4OdbnzF1rN9MjCbNoNLu4GKLxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676927561; 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=FT+MZzo2P/iSxgX8dwLwqLEqMI1OE/9JFkLPTYp/Il4=; b=WxocbtXwYWiZmlzxGbVoY36CMbLQthjVB4odLZXuxyrDKSp6NYSYm+zTS0njj3M706WyGC sO991GkCBS0MzU2OlIMUbK/+zbCjLN7574Yby2frPi7UnUIDqhB2/42tjSzO0Xpfh7D2nX TOQWQ/ANhQBxe1hqyxIwmVwumVEYWlh0G9McH9DCM/WD8LvTVWuHJ6NrBMcLXsjkGkSZPu OrFUdtsXnrGkmI7A1zYpb37tBybj4gBi1S5MW9dEZ7TdJ+AoyYr85rzYrQ15CGfYfNWwZ5 sCmSvkAhD0vF/bo1QcVGImJfXT0ijfMOB8Ira/Y3stCPcUXvf6Q5RDO9wENdng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676927561; a=rsa-sha256; cv=none; b=A9g1yc3QTEg8SdOipkmn9CS69MD7cmiWej5JNZpndXb09W4RBRYG6CRvCOrCmI9ULBcTR6 hiIPveVobzlhKtlNvh2AnYrOs8mFybU1kSeK7loO6ykEV4LL3KIW8bFTGMt2GMi2BRwQJS NLfpNDvxg7ceX9jwv9a3yfhmxidwcd3oFOvjePxGh+Xv2AccamQlnnbanIiucEfLW6EIQs 3yaQXJX/GDfApDGGGDcS869zyIaz3I5Ug1hPAzH5BzbjCkFsUwnAkUgAs9QPaLaDuVR4qF cpXV3MUHwx0fKGC9dNEW6pSZEM+aMm7rNviH/r3E0BG0oqePcD6L1gzrtLn/fQ== 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 4PLFVx4SHFzwGZ; Mon, 20 Feb 2023 21:12:41 +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 31KLCf9Q080360; Mon, 20 Feb 2023 21:12:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31KLCfQB080359; Mon, 20 Feb 2023 21:12:41 GMT (envelope-from git) Date: Mon, 20 Feb 2023 21:12:41 GMT Message-Id: <202302202112.31KLCfQB080359@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: ef6fcc5e2b07 - main - nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup 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: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ef6fcc5e2b0714c859d2e4ba23a55b1fd12f8a4e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=ef6fcc5e2b0714c859d2e4ba23a55b1fd12f8a4e commit ef6fcc5e2b0714c859d2e4ba23a55b1fd12f8a4e Author: Rick Macklem AuthorDate: 2023-02-20 21:11:22 +0000 Commit: Rick Macklem CommitDate: 2023-02-20 21:11:22 +0000 nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup Commit ed03776ca7f4 enabled the vnet front end macros. As such, for kernels built with the VIMAGE option will malloc data and initialize locks on a per-vnet basis, typically via a VNET_SYSINIT(). This patch adds VNET_SYSUNINIT() macros to do the frees of the per-vnet malloc'd data and destroys of per-vnet locks. It also removes the mtx_lock/mtx_unlock calls from nfsrvd_cleancache(), since they are not needed. Discussed with: bz, jamie MFC after: 3 months --- sys/fs/nfs/nfs_commonport.c | 28 +++++++++++++--------------- sys/fs/nfsserver/nfs_nfsdcache.c | 4 ---- sys/fs/nfsserver/nfs_nfsdport.c | 10 +++------- sys/rpc/rpcsec_gss/svc_rpcsec_gss.c | 15 ++++++++++++++- sys/rpc/rpcsec_tls.h | 3 --- sys/rpc/rpcsec_tls/rpctls_impl.c | 18 ++++++++++-------- 6 files changed, 40 insertions(+), 38 deletions(-) diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index 60131ab66184..99482069c36d 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -151,7 +151,6 @@ struct mtx nfs_clstate_mutex; /* local functions */ static int nfssvc_call(struct thread *, struct nfssvc_args *, struct ucred *); -static void nfs_clean(struct prison *); #ifdef __NO_STRICT_ALIGNMENT /* @@ -871,19 +870,6 @@ nfs_pnfsio(task_fn_t *func, void *context) return (ret); } -static void -nfs_clean(struct prison *pr) -{ - - NFSD_CURVNET_SET(pr->pr_vnet); - mtx_destroy(&NFSD_VNET(nfsrv_nfsuserdsock).nr_mtx); - if (pr != &prison0) - free(NFSD_VNET(nfsstatsv1_p), M_TEMP); - /* Clean out the name<-->id cache. */ - nfsrv_cleanusergroup(); - NFSD_CURVNET_RESTORE(); -} - /* * Initialize everything that needs to be initialized for a vnet. */ @@ -902,6 +888,19 @@ nfs_vnetinit(const void *unused __unused) VNET_SYSINIT(nfs_vnetinit, SI_SUB_VNET_DONE, SI_ORDER_ANY, nfs_vnetinit, NULL); +static void +nfs_cleanup(void *unused __unused) +{ + + mtx_destroy(&NFSD_VNET(nfsrv_nfsuserdsock).nr_mtx); + if (!IS_DEFAULT_VNET(curvnet)) + free(NFSD_VNET(nfsstatsv1_p), M_TEMP); + /* Clean out the name<-->id cache. */ + nfsrv_cleanusergroup(); +} +VNET_SYSUNINIT(nfs_cleanup, SI_SUB_VNET_DONE, SI_ORDER_ANY, + nfs_cleanup, NULL); + extern int (*nfsd_call_nfscommon)(struct thread *, struct nfssvc_args *); /* @@ -938,7 +937,6 @@ nfscommon_modevent(module_t mod, int type, void *data) } nfsd_call_nfscommon = NULL; - nfs_clean(&prison0); /* and get rid of the mutexes */ mtx_destroy(&nfs_nameid_mutex); mtx_destroy(&newnfsd_mtx); diff --git a/sys/fs/nfsserver/nfs_nfsdcache.c b/sys/fs/nfsserver/nfs_nfsdcache.c index 2629c795802f..0eb623b6f5ee 100644 --- a/sys/fs/nfsserver/nfs_nfsdcache.c +++ b/sys/fs/nfsserver/nfs_nfsdcache.c @@ -824,13 +824,10 @@ nfsrvd_cleancache(void) int i; for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) { - mtx_lock(&NFSD_VNET(nfsrchash_table)[i].mtx); LIST_FOREACH_SAFE(rp, &NFSD_VNET(nfsrchash_table)[i].tbl, rc_hash, nextrp) nfsrc_freecache(rp); - mtx_unlock(&NFSD_VNET(nfsrchash_table)[i].mtx); } - mtx_lock(&nfsrc_udpmtx); for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) { LIST_FOREACH_SAFE(rp, &NFSD_VNET(nfsrvudphashtbl)[i], rc_hash, nextrp) { @@ -838,7 +835,6 @@ nfsrvd_cleancache(void) } } NFSD_VNET(nfsstatsv1_p)->srvcache_size = 0; - mtx_unlock(&nfsrc_udpmtx); NFSD_VNET(nfsrc_tcpsavedreplies) = 0; } diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 7708f0325494..cee5f96d7199 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -108,8 +108,6 @@ NFSD_VNET_DEFINE_STATIC(struct vfsoptlist, nfsv4root_newopt); NFSD_VNET_DEFINE_STATIC(bool, nfsrv_suspend_nfsd) = false; NFSD_VNET_DEFINE_STATIC(bool, nfsrv_mntinited) = false; -static void nfsrv_cleanup(struct prison *); - static int nfssvc_srvcall(struct thread *, struct nfssvc_args *, struct ucred *); static void nfsvno_updateds(struct vnode *, struct ucred *, struct thread *); @@ -7111,15 +7109,13 @@ VNET_SYSINIT(nfsrv_vnetinit, SI_SUB_VNET_DONE, SI_ORDER_ANY, * done when the jail is destroyed or the module unloaded. */ static void -nfsrv_cleanup(struct prison *pr) +nfsrv_cleanup(const void *unused __unused) { int i; - NFSD_CURVNET_SET(pr->pr_vnet); NFSD_LOCK(); if (!NFSD_VNET(nfsrv_mntinited)) { NFSD_UNLOCK(); - NFSD_CURVNET_RESTORE(); return; } NFSD_VNET(nfsrv_mntinited) = false; @@ -7159,8 +7155,9 @@ nfsrv_cleanup(struct prison *pr) free(NFSD_VNET(nfssessionhash), M_NFSDSESSION); free(NFSD_VNET(nfsv4root_mnt), M_TEMP); NFSD_VNET(nfsv4root_mnt) = NULL; - NFSD_CURVNET_RESTORE(); } +VNET_SYSUNINIT(nfsrv_cleanup, SI_SUB_VNET_DONE, SI_ORDER_ANY, + nfsrv_cleanup, NULL); extern int (*nfsd_call_nfsd)(struct thread *, struct nfssvc_args *); @@ -7201,7 +7198,6 @@ nfsd_modevent(module_t mod, int type, void *data) vn_deleg_ops.vndeleg_disable = NULL; #endif nfsd_call_nfsd = NULL; - nfsrv_cleanup(&prison0); mtx_destroy(&nfsrc_udpmtx); mtx_destroy(&nfs_v4root_mutex); mtx_destroy(&nfsrv_dontlistlock_mtx); diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index dc850996a592..03e185bd912b 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -204,7 +204,7 @@ KGSS_VNET_DEFINE(struct svc_rpc_gss_client_list, svc_rpc_gss_clients); KGSS_VNET_DEFINE_STATIC(uint32_t, svc_rpc_gss_next_clientid) = 1; static void -svc_rpc_gss_init(void *arg) +svc_rpc_gss_init(void *unused __unused) { int i; @@ -222,6 +222,19 @@ svc_rpc_gss_init(void *arg) VNET_SYSINIT(svc_rpc_gss_init, SI_SUB_VNET_DONE, SI_ORDER_ANY, svc_rpc_gss_init, NULL); +static void +svc_rpc_gss_cleanup(void *unused __unused) +{ + + mem_free(KGSS_VNET(svc_rpc_gss_client_hash), + sizeof(struct svc_rpc_gss_client_list) * + svc_rpc_gss_client_hash_size); + if (IS_DEFAULT_VNET(curvnet)) + sx_destroy(&svc_rpc_gss_lock); +} +VNET_SYSUNINIT(svc_rpc_gss_cleanup, SI_SUB_VNET_DONE, SI_ORDER_ANY, + svc_rpc_gss_cleanup, NULL); + bool_t rpc_gss_set_callback(rpc_gss_callback_t *cb) { diff --git a/sys/rpc/rpcsec_tls.h b/sys/rpc/rpcsec_tls.h index ba9a754bd276..a1f77a659ee2 100644 --- a/sys/rpc/rpcsec_tls.h +++ b/sys/rpc/rpcsec_tls.h @@ -76,9 +76,6 @@ enum clnt_stat rpctls_srv_disconnect(uint64_t sec, uint64_t usec, /* Initialization function for rpcsec_tls. */ int rpctls_init(void); -/* Cleanup function for rpcsec_tls. */ -void rpctls_cleanup(void); - /* Get TLS information function. */ bool rpctls_getinfo(u_int *maxlen, bool rpctlscd_run, bool rpctlssd_run); diff --git a/sys/rpc/rpcsec_tls/rpctls_impl.c b/sys/rpc/rpcsec_tls/rpctls_impl.c index 92b8b9481666..4d81b8612d36 100644 --- a/sys/rpc/rpcsec_tls/rpctls_impl.c +++ b/sys/rpc/rpcsec_tls/rpctls_impl.c @@ -109,6 +109,16 @@ rpctls_vnetinit(const void *unused __unused) VNET_SYSINIT(rpctls_vnetinit, SI_SUB_VNET_DONE, SI_ORDER_ANY, rpctls_vnetinit, NULL); +static void +rpctls_cleanup(void *unused __unused) +{ + + free(KRPC_VNET(rpctls_server_handle), M_RPC); + free(KRPC_VNET(rpctls_server_busy), M_RPC); +} +VNET_SYSUNINIT(rpctls_cleanup, SI_SUB_VNET_DONE, SI_ORDER_ANY, + rpctls_cleanup, NULL); + int rpctls_init(void) { @@ -843,11 +853,3 @@ rpctls_getinfo(u_int *maxlenp, bool rpctlscd_run, bool rpctlssd_run) return (enable); } -void -rpctls_cleanup(void) -{ - - free(KRPC_VNET(rpctls_server_handle), M_RPC); - free(KRPC_VNET(rpctls_server_busy), M_RPC); -} -