From nobody Mon Oct 11 01:49:14 2021 X-Original-To: dev-commits-src-main@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 451571807468; Mon, 11 Oct 2021 01:49:15 +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 4HSMCv1QfGz3sLY; Mon, 11 Oct 2021 01:49:15 +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 0AB331861F; Mon, 11 Oct 2021 01:49:15 +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 19B1nETl010779; Mon, 11 Oct 2021 01:49:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B1nEJJ010778; Mon, 11 Oct 2021 01:49:14 GMT (envelope-from git) Date: Mon, 11 Oct 2021 01:49:14 GMT Message-Id: <202110110149.19B1nEJJ010778@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: dfe887b7d226 - main - nfsd: Disable the NFSv4.2 Allocate operation by default List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: dfe887b7d2265a5c6e0132cc03e006eb68223177 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=dfe887b7d2265a5c6e0132cc03e006eb68223177 commit dfe887b7d2265a5c6e0132cc03e006eb68223177 Author: Rick Macklem AuthorDate: 2021-10-11 01:46:02 +0000 Commit: Rick Macklem CommitDate: 2021-10-11 01:46:02 +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. MFC after: 2 weeks --- 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 3b2e6c82276d..fca1df3a716a 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);