From nobody Sun Jun 23 22:48:29 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 4W6mTn4gHtz5P8l9; Sun, 23 Jun 2024 22:48:29 +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 4W6mTn4B2Vz4cwN; Sun, 23 Jun 2024 22:48:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719182909; 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=vRWfKkBAeNmg4SULWJPB6rB4JXfDsp6j288Nyy8spP4=; b=hc2vnlMgndpLVEAcuuh+eNdcj/erTNmI+MtdRK4n+Q3EsW1oI18dWHQJHSqDvhtXusZfzc 9xZEmNgFkBRLGB5mNaMRRnMIPBDfEoRSxNwcXXOR6om/SfEx0QK77rf3Mwk2QB6fChEoC/ ICOzod3p5I5Va8T2iGtPj5PUr4LjRFQ83sPB9WQxYLr7rOFiPVayCEDmY89fQpi2UTYvO+ UxeYtuFyiYYNU3Tt6I1SHqWrh3dkufWO0HNuGgRSu7Zvt3ZAOeQC3JFQQrQmalItRAwbAC hRk7DBMqwSo1H1IsHq8ee7kY2FlvXLGeb5pmzKZo0oNLxvplXnIrWSjh9PdjNg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719182909; a=rsa-sha256; cv=none; b=lvwj963mCqATC0GfXBL+TaN/oh+AOh+djD0yzsVYbIIWFXLveGDDxtWUanYk2vIzRJL6ex umqbmovFAGaMtUdbk+tASFLm/snMqdyJbgCDjVnZKR/FM/Q26ojPSXNPrkMS26whu+mmJT JZfowsd88mE+1BhB7E9O93YCRuW9EEKvYHoM7Zlla5FoEVzr8rm9bLJj+tqLs/iAuJNdiz ILOVncTtDFpnyGc3bG7YS80pjKqQoJwaoRJK09mtOf5bOh+kjBw/cVnD0lYy8OUj5woAuW ps16uaijHhGLLOvXWAJUofqPtCAI+LEx6A+Nf9ZkapDFFreJjzatJUOFOgSOCQ== 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=1719182909; 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=vRWfKkBAeNmg4SULWJPB6rB4JXfDsp6j288Nyy8spP4=; b=lVOhZGhN6YXNuUyrVMW27IeZyqCLMZR4jdkpV7i/jyAkAQ7Fzt/brzTrEQUW5JVT8d47L/ pI2waBfvRmbyl4igOSxTqVmmLdYME8kwApgyByeytffxZWuCql6SoNPPYE/nOgroskYMU4 5Bk9oF7USvJZu7lpulmydCknv7y3nOQUQTzha5KExcQqGrEQeqJZIauKwshd5sQ2M4xZDI gRpMQrEtK/X6pBMYJymoQolJmuW3grG3ON7C/WIkJl/0GLfE6VYbOg5dyldZdHgR+dNntz MtxxTjoaG31osJGdCOVGvXlA2ZNViC/Kg8HJdyQ36JrIP915fGRYnsVHHPaRJg== 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 4W6mTn3TBJzt4F; Sun, 23 Jun 2024 22:48:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45NMmT7H065556; Sun, 23 Jun 2024 22:48:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45NMmTG9065553; Sun, 23 Jun 2024 22:48:29 GMT (envelope-from git) Date: Sun, 23 Jun 2024 22:48:29 GMT Message-Id: <202406232248.45NMmTG9065553@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: 67284d32e5e0 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 67284d32e5e0d5f015d73eeac4342974277263f5 Auto-Submitted: auto-generated The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=67284d32e5e0d5f015d73eeac4342974277263f5 commit 67284d32e5e0d5f015d73eeac4342974277263f5 Author: Rick Macklem AuthorDate: 2024-06-23 22:47:22 +0000 Commit: Rick Macklem CommitDate: 2024-06-23 22:47:22 +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. MFC after: 1 month --- 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 6f5b2855bcf0..fa99a76f492e 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -69,6 +69,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); @@ -178,8 +179,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); @@ -294,6 +293,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