From nobody Fri Dec 30 01:55:53 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 4NjpJ92gCmz2klgH; Fri, 30 Dec 2022 01:55:53 +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 4NjpJ928nkz4FDV; Fri, 30 Dec 2022 01:55:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672365353; 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=8RVRxiQXovDJ7C40ocOcR58OPQ0a/1dI2X9NjN1AjC0=; b=VvBJjAZuQWSc4DDvfLGztOqP/dEIfThnUbGnFVsGPSle9jy0HqJgwTJsI6C8bDrLAKtlxy GwThu19opWozVEEaQn0F16fI9yoUvNahFIo5YXhwgABuN5sPZFSrEWUJugJzBUusa9s3qQ QXDkZHczThSIpXWzkGliV1jKQHDJCZiFpd5GGjZEWozfgrxbxwSrWhoASJklsuOcr9tMzz 2t5ZqFwq1bNpjr2p4p5Lqx5gXdQXBrYFNWnQs1Rg/8KScHblayY3cIPfQ1joK5PtDelsLZ 2Zq/odL1wypnqsegicOnimoWQpQ/D4mwD7kJ/3vkDeYjIkfIFo4VkwBhUnWDlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672365353; 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=8RVRxiQXovDJ7C40ocOcR58OPQ0a/1dI2X9NjN1AjC0=; b=ZSioHwGj+QbkdPjMv+KdgHM7trn2H0ZavhOcRFDz8x3+khy7exBilhxtR3Vj+pZuyWO+vi Rab0Bnz1FO03KK8/81YD/uoK1odQ99ynGu0AZLj2PkarykpvjOHozwS4ofQqzDJdLMFjOY V3WYKqyiO9708d2+gwfofQelisKe6Cn1Ulq1l2s2oFoakw/kngRKSBIqpF2TbDudoeBW+0 x4OWt8PHOxNzshojGuMT7+5r59P1hOjiHwpFwhDLWql5/R2/KIEgF2ni1Nr7vNwDJ11WYQ zAsUFsPdCTKYMchMRK1nYQkCD0nk33T41EYHsxCtkMSKwOev8I0OH9+0Ej6Vvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672365353; a=rsa-sha256; cv=none; b=WIJa5T22w8igxkXwzljuJclZffi1vzb10SOY6rrBidzvtEm6zH5iJaoSNJoPA5uzQ7aFCt vN191rgaHDN9qUmPUjnbJixAieZbH5BHSLnSacPlACHU5RJlp02GII662YUTz0oECzprdq I5sHlwnRISyOG/4sEsa614REMCpAyDX+W5arNLb9zu5C7od6xIC1sDxp9FiKVsU3UpCO97 +d7pRN3OUc5+2wu5LtAGqAb9jp5uINSBBCzPtcZlAxhK2z/bE/TJoEcrMkq4sjqLyorBBe x1jjGSqgFIUH/eh8tFGrvAvN60baA11xryhPwvC7JGGVv0aR6iFGyHSmPl8ZRw== 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 4NjpJ91Cldzqy8; Fri, 30 Dec 2022 01:55:53 +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 2BU1trwS078008; Fri, 30 Dec 2022 01:55:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BU1trwe078007; Fri, 30 Dec 2022 01:55:53 GMT (envelope-from git) Date: Fri, 30 Dec 2022 01:55:53 GMT Message-Id: <202212300155.2BU1trwe078007@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: 1815de4fedee - stable/13 - nfsd: Handle file systems without a VOP_VPTOFH() 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: 1815de4fedee32cb923450d59190dc5aff5a63f4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=1815de4fedee32cb923450d59190dc5aff5a63f4 commit 1815de4fedee32cb923450d59190dc5aff5a63f4 Author: Rick Macklem AuthorDate: 2022-12-23 23:17:34 +0000 Commit: Rick Macklem CommitDate: 2022-12-30 01:54:32 +0000 nfsd: Handle file systems without a VOP_VPTOFH() Unlike NFSv3, the NFSv4 server follows mount points within the file system tree below the NFSv4 root directory. If there is a file system mounted within this subtree that returns EOPNOTSUPP for VOP_VPTOFH(), the NFSv4 server would return an error for the mount point entry. This resulted in an "I/O error" report from the Linux NFSv4 client. It also put an error code in the Readdir reply that is not defined in the NFSv4 RFCs. For the FreeBSD NFSv4 client, the entry with the error would be ignored, which I think is reasonable behaviour for a mounted file system that can never be exported. This patch changes the NFSv4 server behaviour to ignore the mount point entry and not send it in the Readdir reply. It also changes the behaviour of Lookup for the entry so that it replies ENOENT for the mount point directory, so that it is consistent with no entry in the Readdir reply. With these two changes, the Linux client behaviour is the same as the FreeBSD client behaviour. It also avoids putting an unknown error on the wire to the client. (cherry picked from commit 6fd6a0e342fbfb8513ae56105cf0f85f55c6276e) --- sys/fs/nfsserver/nfs_nfsdport.c | 11 +++++++++-- sys/fs/nfsserver/nfs_nfsdserv.c | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 51c4d59e5380..407987aa767f 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -2725,15 +2725,22 @@ again: * For NFSv4 the behavior is controlled by * RDATTRERROR: we either ignore the error or * fail the request. + * The exception is EOPNOTSUPP, which can be + * returned by nfsvno_getfh() for certain + * file systems, such as devfs. This indicates + * that the file system cannot be exported, + * so just skip over the entry. * Note that RDATTRERROR is never set for NFSv3. */ if (r != 0) { if (!NFSISSET_ATTRBIT(&attrbits, - NFSATTRBIT_RDATTRERROR)) { + NFSATTRBIT_RDATTRERROR) || + r == EOPNOTSUPP) { vput(nvp); if (needs_unbusy != 0) vfs_unbusy(new_mp); - if ((nd->nd_flag & ND_NFSV3)) + if ((nd->nd_flag & ND_NFSV3) || + r == EOPNOTSUPP) goto invalid; nd->nd_repstat = r; break; diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 75e764b9b51e..2d1048d26486 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -647,8 +647,15 @@ nfsrvd_lookup(struct nfsrv_descript *nd, __unused int isdgram, * non-exported volumes during NFSv4 mounting. */ nd->nd_repstat = ENOENT; - if (nd->nd_repstat == 0) + if (nd->nd_repstat == 0) { nd->nd_repstat = nfsvno_getfh(vp, fhp, p); + /* + * EOPNOTSUPP indicates the file system cannot be exported, + * so just pretend the entry does not exist. + */ + if (nd->nd_repstat == EOPNOTSUPP) + nd->nd_repstat = ENOENT; + } if (!(nd->nd_flag & ND_NFSV4) && !nd->nd_repstat) nd->nd_repstat = nfsvno_getattr(vp, &nva, nd, p, 1, NULL); if (vpp != NULL && nd->nd_repstat == 0)