From nobody Tue Jul 23 00:55:25 2024 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 4WSdws5bJ6z5QYQP; Tue, 23 Jul 2024 00:55:25 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WSdws51rZz42XY; Tue, 23 Jul 2024 00:55:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721696125; 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=/wceRLETung1fifr5VeAfDAkSPFeLltQjx4NVrwQ9f0=; b=JMYM6dr7nbzmGJ5DfSI7LlxTeU86I+iibq0CdhwNdYY1TLuHxBJGWj5CRyaIsKyybN/PLW eD3Xvd1o3vvsXVGOJZz44a0X5G/BFTDA9zpbLCbBG2GGAKhRkUnyYlNODJZqff7oCNuFAi um2sU9G1KT6woeKXsVvvSDO/ugRZS/0ps7llczC7OpHdU7ZJ5Z8PIrGyxS/Vg5z5ZH1/6G 46yP6D7itNUSPOex66d/y+QIsSm+AVy/S8c5FK2+50kAJteiR9uV0wKp5VxbiPyxIsPnKd lqh6B5KU4b4mnKFkJF76U5IHWWL1oDjNogOYNqLsb0IFiky2qfKTa9fEOgvAJg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721696125; a=rsa-sha256; cv=none; b=WSMurWAeSsQL2XPo8RKAIuOXVlDNBdldcGNKPiLV1F0pf2B5Vy1dpLV0jK2wzrHZr3abik JMpEaIPSlAwFLSCMFKzNBCAayhs9MQAKiHZeQXIDi+sIr67DaGnpHNn/WwR3qdhrPuxtlM SxVeUfYQejR6pxlbqmJ/BarOJpHi6o/GHD9/cdDa6LM8+P6iaJyN/HCL/yWH8CMFYVk/bl fUW4ekSbSMnSkUVpH3nvT02qFXqWBkAXIs1mOKJMAP4FdvJW9sqVB8Aty7tWB60g+jJ5+0 XiAifLQd27D9iQuQpbCW+Ck5lfalUe68BQAN1NQNOoscTCpTAp3ojaP4ExyfvQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721696125; 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=/wceRLETung1fifr5VeAfDAkSPFeLltQjx4NVrwQ9f0=; b=w8ITWNL7HXQYP58ouImhej5zrIv2V4Y9nmyB5iig6dPZUiLkXdOLkbyl/LDHIPmqemDQqH zkThShDkYz0Ra3yJFWJJnMKBGXDA55c/8lCmYKgq3LT+c3cyLsH4PVkYKqQWEoNYZ6HkCZ xltruzfQMsi4qa9ZEkRJdu4zx5iyo7l7zQshGzvXZXIkIaphINZJYsIsEM2ueUosJixhvg 4B5qDmh/v3WPnIBcCSxN7X9NdFdTs8YhgrpI20J7GGmz31U41vUdbHeFgx7rJhg6eioyah SWb+PV/WxcPDoym8Y/neTBVkdjz1rO+RVRqqJZOmm+q/xLDAvbXivQGFfhl4Xw== 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 4WSdws4QbZz16Cd; Tue, 23 Jul 2024 00:55:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46N0tP0P050588; Tue, 23 Jul 2024 00:55:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46N0tP28050585; Tue, 23 Jul 2024 00:55:25 GMT (envelope-from git) Date: Tue, 23 Jul 2024 00:55:25 GMT Message-Id: <202407230055.46N0tP28050585@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: f84ac01e1829 - stable/13 - nfsd: Make modifying vfs.nfsd.enable_locallocks safe 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/13 X-Git-Reftype: branch X-Git-Commit: f84ac01e1829a6f3e48af076041120692c00ccb0 Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f84ac01e1829a6f3e48af076041120692c00ccb0 commit f84ac01e1829a6f3e48af076041120692c00ccb0 Author: Rick Macklem AuthorDate: 2024-06-23 22:47:22 +0000 Commit: Rick Macklem CommitDate: 2024-07-23 00:35:02 +0000 nfsd: Make modifying vfs.nfsd.enable_locallocks safe Commit dfaeeacc2cc2 modified clientID handling so that it could be done with only a mutex lock held when vfs.nfsd.enable_locallocks is 0. This makes it unsafe to change the setting of vfs.nfsd.enable_locallocks when nfsd threads are active. This patch forces all nfsd threads to be blocked when the value of vfs.nfsd.enable_locallocks is changed, so that it is done safely. (cherry picked from commit 67284d32e5e0d5f015d73eeac4342974277263f5) --- sys/fs/nfsserver/nfs_nfsdport.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 46be3e051056..f412451e4e35 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -70,6 +70,7 @@ extern int nfsrv_maxpnfsmirror; extern uint32_t nfs_srvmaxio; extern int nfs_bufpackets; extern u_long sb_max_adj; +extern struct nfsv4lock nfsv4rootfs_lock; NFSD_VNET_DECLARE(int, nfsrv_numnfsd); NFSD_VNET_DECLARE(struct nfsrv_stablefirst, nfsrv_stablefirst); @@ -177,8 +178,6 @@ SYSCTL_INT(_vfs_nfsd, OID_AUTO, commit_miss, CTLFLAG_RW, &nfs_commit_miss, 0, ""); SYSCTL_INT(_vfs_nfsd, OID_AUTO, issue_delegations, CTLFLAG_RW, &nfsrv_issuedelegs, 0, "Enable nfsd to issue delegations"); -SYSCTL_INT(_vfs_nfsd, OID_AUTO, enable_locallocks, CTLFLAG_RW, - &nfsrv_dolocallocks, 0, "Enable nfsd to acquire local locks on files"); SYSCTL_INT(_vfs_nfsd, OID_AUTO, debuglevel, CTLFLAG_RW, &nfsd_debuglevel, 0, "Debug level for NFS server"); NFSD_VNET_DECLARE(int, nfsd_enable_stringtouid); @@ -293,6 +292,38 @@ SYSCTL_PROC(_vfs_nfsd, OID_AUTO, srvmaxio, CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, sysctl_srvmaxio, "IU", "Maximum I/O size in bytes"); +static int +sysctl_dolocallocks(SYSCTL_HANDLER_ARGS) +{ + int error, igotlock, newdolocallocks; + + newdolocallocks = nfsrv_dolocallocks; + error = sysctl_handle_int(oidp, &newdolocallocks, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (newdolocallocks == nfsrv_dolocallocks) + return (0); + if (jailed(curthread->td_ucred)) + return (EINVAL); + + NFSLOCKV4ROOTMUTEX(); + do { + igotlock = nfsv4_lock(&nfsv4rootfs_lock, 1, NULL, + NFSV4ROOTLOCKMUTEXPTR, NULL); + } while (!igotlock); + NFSUNLOCKV4ROOTMUTEX(); + + nfsrv_dolocallocks = newdolocallocks; + + NFSLOCKV4ROOTMUTEX(); + nfsv4_unlock(&nfsv4rootfs_lock, 0); + NFSUNLOCKV4ROOTMUTEX(); + return (0); +} +SYSCTL_PROC(_vfs_nfsd, OID_AUTO, enable_locallocks, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, + sysctl_dolocallocks, "IU", "Enable nfsd to acquire local locks on files"); + #define MAX_REORDERED_RPC 16 #define NUM_HEURISTIC 1031 #define NHUSE_INIT 64