From nobody Sun Sep 18 22:16:45 2022 X-Original-To: dev-commits-src-branches@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 4MW2GP53Kdz4cRN2; Sun, 18 Sep 2022 22:16:45 +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 4MW2GP4R3jz48BH; Sun, 18 Sep 2022 22:16:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663539405; 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=Z6FCTplTF3BaIzzci0KHCH26icrZBYmdCUS/jrtA48I=; b=EWlriL+NxsjNOmfTPWBvxoWinJkhidRFCvf07RtuBzUBUqqv+aAlymGV8+jf29o/tpC7g2 eLD72iIg7y0evkgZ6mDzUkxaAKcSJMeCmGgb1TYsZQKVbv+nDMGUwa9pdUvUW/vxn5aJeJ bKlmhC45D7nj8Vpj3QyNsTjkyJCH446dHrCj6g51z6+4y/MyuCJT5clNsoWeEb54GEq760 7MPOkxRQIkEE2bN+D3qgCrGVqSFf/SOS4ubPCEJKaFZxciQdkyvHNgKeQ1TBDw2wJKEmgh PLOacP6K1xbwA+UABZdKL7qlqF+EaMrBdPfXuQbwlQoqPEboiOWpErBaA1RSwQ== 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 4MW2GP3RY7z19dP; Sun, 18 Sep 2022 22:16:45 +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 28IMGjjU048923; Sun, 18 Sep 2022 22:16:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28IMGjK1048922; Sun, 18 Sep 2022 22:16:45 GMT (envelope-from git) Date: Sun, 18 Sep 2022 22:16:45 GMT Message-Id: <202209182216.28IMGjK1048922@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: 5830e7391d9f - stable/13 - nfscl: Allow "nolockd" to work for NFSv4 mounts List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: 5830e7391d9f33e4b63ea9bfcc130a1547683bf2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663539405; 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=Z6FCTplTF3BaIzzci0KHCH26icrZBYmdCUS/jrtA48I=; b=iSXSIf8HR7yiPwYwGurQmKMlqDkhaWh1NYW7lUOaQlcV3gvPmjs3KnxC3uGMDX//dVnRoi IPWQDyWZwLv8uc1eo2dSgUBcE1uGuyuT4WvtQebGpEj+E3WRw20wVXhcx3VPdsZJp+VX5Q CoLiJtcfmuEn4Soy/ql6BcekAFh0Yg07twvMwg0tjRn/M214a2VboMQ2Bp+tImO1kKxVH0 hyl9VoT5bsR/yS8a+fjy19jFmqcyCEp+Qbt9ql2FgtUEC1S62LjnQ8Ym0b4T5xDlYGjVx8 b0gkm/FW739cHrNrrTVu5eMyMRG3RpZYXsg+/BRLRtbEcAKDoum8gjw8zc78Bg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663539405; a=rsa-sha256; cv=none; b=HtJhhS5814NM94qZ5F1QqUKNXbFxRw/DuVz6x1Czn1WTYPFx0AQLiFwIyIV/RGJu0SsetN ORvtPu0OreRDyT9G66uEQ+ar2ECibhQOVwBS3KSVCOkyS1GxsLbKo+od7x0oFmUjfc/Hnn 5tX6QFMy/TIUCiF4nvha7cdwPLyMm9kSHSogzP7HvIlckGSd0BETlGewwwWlt5sfUGYQUT eABrhXjhVN6YpgPBq+PGULH4ZpF2aBJ9wX6aIK7fCiFBENxvVkEElvtfuGOT0n9axANQIU dDIx11TlOuOEDLMadRzzT82IrRx89N61kqh/hsgW34j8Zl8R12bwqaIvSzylSQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=5830e7391d9f33e4b63ea9bfcc130a1547683bf2 commit 5830e7391d9f33e4b63ea9bfcc130a1547683bf2 Author: Rick Macklem AuthorDate: 2022-09-04 20:09:33 +0000 Commit: Rick Macklem CommitDate: 2022-09-18 22:13:07 +0000 nfscl: Allow "nolockd" to work for NFSv4 mounts Commit 40ada74ee1da modified the NFSv4.1/4.2 client so that it would issue a DestroySession to the server when all session slots are marked bad. This handles the case where session slots get broken when "intr" or "soft" NFSv4 fairly well.1/4.2 mounts are done. There are two other cases where having an NFSv4.1/4.2 RPC attempt terminate without completion can leave state in a non-determinate condition. One is file locking RPCs. If the "nolockd" option is used, this avoids file locking RPCs by doing locking locally within the client. The other is Open locks, but since all FreeBSD Open locks are done with OPEN_SHARE_DENY_NONE, the locking state for these should not be critical. This patch enables use of "nolockd" for NFSv4 mounts, so that it can be combined with "intr" and/or "soft", making the latter more usable. Use of "intr" or "soft" NFSv4 mounts are still not recommended, but when combined with "nolockd" should now work fairly well. A man page update will be done as a separate commit. (cherry picked from commit 33721eb991d868dbcad4726872d95ddd8f04ec27) --- sys/fs/nfsclient/nfs_clvfsops.c | 4 ++-- sys/fs/nfsclient/nfs_clvnops.c | 52 ++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 55941170fc69..be863cc9d70a 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -2130,8 +2130,8 @@ void nfscl_retopts(struct nfsmount *nmp, char *buffer, size_t buflen) ",noncontigwr", &buf, &blen); nfscl_printopt(nmp, (nmp->nm_flag & (NFSMNT_NOLOCKD | NFSMNT_NFSV4)) == 0, ",lockd", &buf, &blen); - nfscl_printopt(nmp, (nmp->nm_flag & (NFSMNT_NOLOCKD | NFSMNT_NFSV4)) == - NFSMNT_NOLOCKD, ",nolockd", &buf, &blen); + nfscl_printopt(nmp, (nmp->nm_flag & NFSMNT_NOLOCKD) != 0, ",nolockd", + &buf, &blen); nfscl_printopt(nmp, (nmp->nm_flag & NFSMNT_RDIRPLUS) != 0, ",rdirplus", &buf, &blen); nfscl_printopt(nmp, (nmp->nm_flag & NFSMNT_KERB) == 0, ",sec=sys", diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index a6040ce58290..a92875aae6ed 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3283,7 +3283,32 @@ nfs_advlock(struct vop_advlock_args *ap) error = NFSVOPLOCK(vp, LK_SHARED); if (error != 0) return (EBADF); - if (NFS_ISV4(vp) && (ap->a_flags & (F_POSIX | F_FLOCK)) != 0) { + nmp = VFSTONFS(vp->v_mount); + if (!NFS_ISV4(vp) || (nmp->nm_flag & NFSMNT_NOLOCKD) != 0) { + if ((nmp->nm_flag & NFSMNT_NOLOCKD) != 0) { + size = np->n_size; + NFSVOPUNLOCK(vp); + error = lf_advlock(ap, &(vp->v_lockf), size); + } else { + if (nfs_advlock_p != NULL) + error = nfs_advlock_p(ap); + else { + NFSVOPUNLOCK(vp); + error = ENOLCK; + } + } + if (error == 0 && ap->a_op == F_SETLK) { + error = NFSVOPLOCK(vp, LK_SHARED); + if (error == 0) { + /* Mark that a file lock has been acquired. */ + NFSLOCKNODE(np); + np->n_flag |= NHASBEENLOCKED; + NFSUNLOCKNODE(np); + NFSVOPUNLOCK(vp); + } + } + return (error); + } else if ((ap->a_flags & (F_POSIX | F_FLOCK)) != 0) { if (vp->v_type != VREG) { error = EINVAL; goto out; @@ -3317,7 +3342,6 @@ nfs_advlock(struct vop_advlock_args *ap) * state structure cannot exist for the file. * Only done for "oneopenown" NFSv4.1/4.2 mounts. */ - nmp = VFSTONFS(vp->v_mount); if (NFSHASNFSV4N(nmp) && NFSHASONEOPENOWN(nmp)) { NFSLOCKNODE(np); np->n_flag |= NMIGHTBELOCKED; @@ -3384,30 +3408,6 @@ nfs_advlock(struct vop_advlock_args *ap) np->n_flag |= NHASBEENLOCKED; NFSUNLOCKNODE(np); } - } else if (!NFS_ISV4(vp)) { - if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) { - size = VTONFS(vp)->n_size; - NFSVOPUNLOCK(vp); - error = lf_advlock(ap, &(vp->v_lockf), size); - } else { - if (nfs_advlock_p != NULL) - error = nfs_advlock_p(ap); - else { - NFSVOPUNLOCK(vp); - error = ENOLCK; - } - } - if (error == 0 && ap->a_op == F_SETLK) { - error = NFSVOPLOCK(vp, LK_SHARED); - if (error == 0) { - /* Mark that a file lock has been acquired. */ - NFSLOCKNODE(np); - np->n_flag |= NHASBEENLOCKED; - NFSUNLOCKNODE(np); - NFSVOPUNLOCK(vp); - } - } - return (error); } else error = EOPNOTSUPP; out: