From nobody Mon Sep 19 00:51:30 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 4MW5hy68sZz4cs6b; Mon, 19 Sep 2022 00:51:30 +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 4MW5hy5d5Dz3Mpv; Mon, 19 Sep 2022 00:51:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663548690; 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=979NmMtaNLI36xpHegamZljHHxO+jlLE2HBRuoJ18pU=; b=ELPSILiVeBpVCFIf5RzeD7EEcwFpB8KSKBwNcb1aFeoaPdoXfPZQgqTY1ALbwnabDsN/p2 dhEbCzNNzWPK3yVDJojTda65NNKoLAFwMKqWau5LnetVRXeJOztpM25Ub6dCcCo4g6DzNp d3CclciAdVuz9P5U6pkLQasdqVhlPHDl4SK2OUZIuSXhkDzB98AUmVcPmbpPGXVx7kwp37 DLr+TMHPvYFgMQwBbt1ol5AnSXTeiSpdXWNjwUtHA+VTKSlsHAP03g+ajdA1Cpy+tbld8r px9KY1wTbFsZdK69nXN2HJ/0+97SqsNIU8NPCtM5WMqaqPBaG2nMQYXqxE8gjw== 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 4MW5hy4h0Qz1C7r; Mon, 19 Sep 2022 00:51:30 +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 28J0pUqo043741; Mon, 19 Sep 2022 00:51:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28J0pUF7043740; Mon, 19 Sep 2022 00:51:30 GMT (envelope-from git) Date: Mon, 19 Sep 2022 00:51:30 GMT Message-Id: <202209190051.28J0pUF7043740@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: fa5a74500544 - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: fa5a74500544efa21b32801b2a3734b9f886b4ac Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663548690; 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=979NmMtaNLI36xpHegamZljHHxO+jlLE2HBRuoJ18pU=; b=FXAbmOU8/f4T+sa4HJnEnEu93THI5tCQMmx/wy/D98ISlF+ABcywqnz44/T9T9FsffN5Zm 556vfUk0m+h/ctO0Sfc2kcCa9HSH99gfBsTE5ftsNCOLr+Hfe9e9Ujs0OPucJyZ3FJ7SnX t87F2ezKwHf1kVsLqnfYHqpQWBNYYy69LerMv5i2goOPawjaaic16DKoH3Szj1cTmpWLgP A+qJRlrkZ5NhWeHyvhujMPtIogCnNMj+USpQihkUkT+WpF5dOiKWkYD8D9LvM2Nqx/Cd0y /8j6CmBTcEt4zzrmouU1R9wY4ez+dKUMLo++VcBROzh8BYs6LljYBsEwbSb+Rg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663548690; a=rsa-sha256; cv=none; b=p+l8rUvS8NXl/fFCocbXINUH6qBvc76XfoHIAxRPOdWuss694s+SpD3Eo8lWR9XPCmi3KA 7t1mWlbWniPxX3FWeUtN0/cnU9BEXwtEUJVa34n9GMdg65kxGO5MMoTVZ78vhmQArwBGE8 kwujCtwtQ/jqQDBwqPwOQmKtvOQogiVTq2m8hZdTYuTpQTAthMXtjZpeBhmVGNR2+zano7 CUY9iHivWtdTdA0XKjkeMBxE4+E0qxJIErYt/A0RNeQneF9ELHxNazdmJ3U8muD4GlM/Ft iLqndt30uSz08cRsyfJI670iLaMxUpQQCrlutcsi2UIs74hjytrIXXCvYSSTfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=fa5a74500544efa21b32801b2a3734b9f886b4ac commit fa5a74500544efa21b32801b2a3734b9f886b4ac Author: Rick Macklem AuthorDate: 2022-09-04 20:09:33 +0000 Commit: Rick Macklem CommitDate: 2022-09-19 00:47:21 +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 | 51 ++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index b839ad347696..f0bd9bd3aeeb 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -2027,8 +2027,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 e37827deb723..64386afccb4c 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3188,11 +3188,37 @@ nfs_advlock(struct vop_advlock_args *ap) struct vattr va; int ret, error = EOPNOTSUPP; u_quad_t size; + struct nfsmount *nmp; ret = NFSVOPLOCK(vp, LK_SHARED); if (ret != 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, 0); + error = lf_advlock(ap, &(vp->v_lockf), size); + } else { + if (nfs_advlock_p != NULL) + error = nfs_advlock_p(ap); + else { + NFSVOPUNLOCK(vp, 0); + 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, 0); + } + } + return (error); + } else if ((ap->a_flags & (F_POSIX | F_FLOCK)) != 0) { if (vp->v_type != VREG) { NFSVOPUNLOCK(vp, 0); return (EINVAL); @@ -3279,29 +3305,6 @@ nfs_advlock(struct vop_advlock_args *ap) } NFSVOPUNLOCK(vp, 0); return (0); - } else if (!NFS_ISV4(vp)) { - if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) { - size = VTONFS(vp)->n_size; - NFSVOPUNLOCK(vp, 0); - error = lf_advlock(ap, &(vp->v_lockf), size); - } else { - if (nfs_advlock_p != NULL) - error = nfs_advlock_p(ap); - else { - NFSVOPUNLOCK(vp, 0); - 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, 0); - } - } } else NFSVOPUNLOCK(vp, 0); return (error);