From nobody Mon Oct 25 21:36:36 2021 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 DD447182FADB; Mon, 25 Oct 2021 21:36:36 +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 4HdSvS5tzKz3nMQ; Mon, 25 Oct 2021 21:36:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A61E4107CF; Mon, 25 Oct 2021 21:36:36 +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 19PLaa5l024766; Mon, 25 Oct 2021 21:36:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PLaa8Q024765; Mon, 25 Oct 2021 21:36:36 GMT (envelope-from git) Date: Mon, 25 Oct 2021 21:36:36 GMT Message-Id: <202110252136.19PLaa8Q024765@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: b575f97c831e - stable/13 - nfsd: Disable the NFSv4.2 Allocate operation by default 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/stable/13 X-Git-Reftype: branch X-Git-Commit: b575f97c831eccc4f9e8cbd707f9f58df37440c5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=b575f97c831eccc4f9e8cbd707f9f58df37440c5 commit b575f97c831eccc4f9e8cbd707f9f58df37440c5 Author: Rick Macklem AuthorDate: 2021-10-11 01:46:02 +0000 Commit: Rick Macklem CommitDate: 2021-10-25 21:32:42 +0000 nfsd: Disable the NFSv4.2 Allocate operation by default Some exported file systems, such as ZFS ones, cannot do VOP_ALLOCATE(). Since an NFSv4.2 server must either support the Allocate operation for all file systems or not support it at all, define a sysctl called vfs.nfsd.enable_v42allocate to enable the Allocate operation. This sysctl is false by default and can only be set true if all exported file systems (or all DSs for a pNFS server) can perform VOP_ALLOCATE(). Unfortunately, there is no way to know if a ZFS file system will be exported once the nfsd is operational, even if there are none exported when the nfsd is started up, so enabling Allocate must be done manually for a server configuration. This problem was detected during a recent NFSv4 interoperability testing event held by the IETF working group. (cherry picked from commit dfe887b7d2265a5c6e0132cc03e006eb68223177) --- sys/fs/nfsserver/nfs_nfsdserv.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index ab02df2c4a46..7ca766c99069 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -91,6 +91,14 @@ SYSCTL_STRING(_vfs_nfsd, OID_AUTO, owner_major, CTLFLAG_RWTUN, static uint64_t nfsrv_owner_minor; SYSCTL_U64(_vfs_nfsd, OID_AUTO, owner_minor, CTLFLAG_RWTUN, &nfsrv_owner_minor, 0, "Server owner minor"); +/* + * Only enable this if all your exported file systems + * (or pNFS DSs for the pNFS case) support VOP_ALLOCATE. + */ +static bool nfsrv_doallocate = false; +SYSCTL_BOOL(_vfs_nfsd, OID_AUTO, enable_v42allocate, CTLFLAG_RW, + &nfsrv_doallocate, 0, + "Enable NFSv4.2 Allocate operation"); /* * This list defines the GSS mechanisms supported. @@ -5324,6 +5332,16 @@ nfsrvd_allocate(struct nfsrv_descript *nd, __unused int isdgram, nfsquad_t clientid; nfsattrbit_t attrbits; + if (!nfsrv_doallocate) { + /* + * If any exported file system, such as a ZFS one, cannot + * do VOP_ALLOCATE(), this operation cannot be supported + * for NFSv4.2. This cannot be done 'per filesystem', but + * must be for the entire nfsd NFSv4.2 service. + */ + nd->nd_repstat = NFSERR_NOTSUPP; + goto nfsmout; + } gotproxystateid = 0; NFSM_DISSECT(tl, uint32_t *, NFSX_STATEID + 2 * NFSX_HYPER); stp->ls_flags = (NFSLCK_CHECK | NFSLCK_WRITEACCESS); @@ -5390,9 +5408,13 @@ nfsrvd_allocate(struct nfsrv_descript *nd, __unused int isdgram, nd->nd_repstat = nfsrv_lockctrl(vp, &stp, &lop, NULL, clientid, &stateid, exp, nd, curthread); + NFSD_DEBUG(4, "nfsrvd_allocate: off=%jd len=%jd stat=%d\n", + (intmax_t)off, (intmax_t)len, nd->nd_repstat); if (nd->nd_repstat == 0) nd->nd_repstat = nfsvno_allocate(vp, off, len, nd->nd_cred, curthread); + NFSD_DEBUG(4, "nfsrvd_allocate: aft nfsvno_allocate=%d\n", + nd->nd_repstat); vput(vp); NFSEXITCODE2(0, nd); return (0);