From nobody Sun Sep 04 20:10:43 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 4MLN7R638pz4bShV; Sun, 4 Sep 2022 20:10:43 +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 4MLN7R5czQz3HHs; Sun, 4 Sep 2022 20:10:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662322243; 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=4135v4qUxF4la8leIcvf2Ns87OSm52sRlWK62FJ2GfQ=; b=jFDHd55KN42yPAyeAAytPRnjND5zodhA4Xtrdg4OJ/WMtbCqf4Qa75i+EdkvzI2s9V3aEu wqqLlyK5WHgslitBNr8FM12zj55+8ep+9Yn+cWPSG5WW+vSNwqEqYDhib+gx6b78KKuHqL 0O2/H8T1lUC8odTXtAbPVZhtgQNSOIvLlFtnKVcjwl19Qc9HelRYPCwWZOXCKHwNlk0+eA G1Xiap/HzVH8d6NMTKPO1JonpaqrwD61N5KIR93Vhn0Fdttf+MNqhwlgBa/VfW8/y/soAK SdYDcWkUt/kXvRdRCxwJcMn/Qhnk/ML/aJ2u58D07Vbo6E1yp5Z2Y4oIuKCOeA== 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 4MLN7R4h2lzbbk; Sun, 4 Sep 2022 20:10:43 +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 284KAhlj006247; Sun, 4 Sep 2022 20:10:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 284KAhJ2006246; Sun, 4 Sep 2022 20:10:43 GMT (envelope-from git) Date: Sun, 4 Sep 2022 20:10:43 GMT Message-Id: <202209042010.284KAhJ2006246@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: 33721eb991d8 - main - nfscl: Allow "nolockd" to work for NFSv4 mounts 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: 33721eb991d868dbcad4726872d95ddd8f04ec27 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662322243; 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=4135v4qUxF4la8leIcvf2Ns87OSm52sRlWK62FJ2GfQ=; b=pFv32pN//8FcEgpuQPT3opr9XFztuVbw+wgUzvExMpDGUcTXW5iQ1poGxF+MvtEseed/Jf bTQbqOoZ2tsy3JadLxGdVsGzdnxdU+zcDn0k82DTyR2U9yJlbyrzSjaWvHj44eBod19XmR XAx9RPniZeUr3LuQqLR1JDW8MKFDHGSqf+blQ3V+MHZdvXeW7A90xIJ00JHsjuwHqN/EMb oKmRP9wxb/gonXcU5g5csna0lBISAqOWWhQoBQqchT4jWJb5zXZEnGjfPH7SgfxRQ+pIH+ 898RO6rLtnXHhaz8aryKhafcVTzPFZA/cnBuCXZNWf/PcXqHxqkMFkq4XyXhUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662322243; a=rsa-sha256; cv=none; b=VWvw7ci5dwf9V8+SKfNmQc2zoSSWLSiEh+nO35zMfmBvZ/y7FdEwHfau+SNd/n0u/IFk+E gsweeE3xi4Teyq8VZ6hk/a06NkHKXaz8W/YePqTxOUi+eSuPLJyolFrU1pBBkeGQpFlN/G v82x+MDqWCJBy46i/gz8kpUN1s/ChD3S7RiV4dITZEpNSAz/G2YPDJUy918/iIzMl1bMtx CYcrNoCOQj/o06tX2A81XfXPPcX2MY+/KVH5w+gwY019V8yeoVLr3KvnFM1UPQ6VFEVdZu I6ZPWto6K6UJETCzG+o/EXao6uUFp1Ny6IaZHRnsOL/baObCxybcZWGuxvFdEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=33721eb991d868dbcad4726872d95ddd8f04ec27 commit 33721eb991d868dbcad4726872d95ddd8f04ec27 Author: Rick Macklem AuthorDate: 2022-09-04 20:09:33 +0000 Commit: Rick Macklem CommitDate: 2022-09-04 20:09:33 +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. MFC after: 2 weeks --- 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 8dc7036242e1..7635835ef0e0 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -2131,8 +2131,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 d72c2542f32f..b1a174f171fa 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3289,7 +3289,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; @@ -3323,7 +3348,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; @@ -3390,30 +3414,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: