From nobody Thu Nov 16 23:56:08 2023 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 4SWcPP0Mjxz51G0S; Thu, 16 Nov 2023 23:56:09 +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 4SWcPN6r02z3M6H; Thu, 16 Nov 2023 23:56:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700178969; 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=1zbXskylFwGKwTo0IqNAwDum12aBFI0knWjGIYxtftA=; b=CPGD/tkx0pWtbRseR30fgVb6pmd8s1eRTOWi4qaui76KnTjTtvUHRPMUAlVGoq7lID40m/ ZAeY2qdT8cKnSN0Nl7YfX8jB3qJoB++0+pRtdZfkARTu9FMwfYUf4FdQRkkUrE+DFU47oV H2o2C3L+GJ/a29o7qHWCCPY4mDMk/PQHONdrSFbk+OC5hHTzO3HdZyLUS9pWn2wr8+TBlV amX2a0TK8ZxIooYPKbiptuZP5wmqtea3IvypL58EFC8TyZ0ynDqYqnbcaY3daVMF20yKat aqci+EmG1+zloFCmytr0B5PR41iKvq6Ptgpe0OAqKe/iD+FwRI+HxTxJaWvXRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700178969; 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=1zbXskylFwGKwTo0IqNAwDum12aBFI0knWjGIYxtftA=; b=ML2/8hqSW0tSQ8gpYz4xwfB8Kh/EmEzVjJPlTUFMX8lSTSa45qgf4u31JSLo5kDjjgFUfQ EIhs9+hfRU5gPBeagc0+v69g3OEFewdnzzkbzQIO6Q/F6cfChUXkgnArsaG8RX5siqvFnh 2bD5bYmOfwNA7YYVgAkdJHsvckzReadUEBhJMwBK/cD5Jh+KiXwuNS1TMiKXvdBt/u337K zoTVv24bLJMH7VyFyfmA3+bifEWHkDgTKZF9it0UapJ026ExpAcq2278wyIGrq9TkRb4aG coi3X7s/hijXWv9wXdOQOepSr1tIS/xgP8wCbLuyk/AKUO3ebJgvZKzRJlflcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700178969; a=rsa-sha256; cv=none; b=no1IFgBN4Vv3Ty32umcc6lKtfK2L3+FOJVWsosrBkVPzevzMeaVQBEP2o9UCDkNEgXgNwP Nhs81bbbKPlHvLTjKAtuYQGnLpQMO9GX1VvnJKsP1Ne/EZ20rv3bBG5iSDrfcLGu8BZj9p kjYeomWmkN0DbumvixCEiL554bzGTlwph5dUOJWr7QbjBQSNPf/m4ra0MFJxVzhc+/DkPk looqBqErGOunDPvfJPzytPhHw5cluUr1nD6Zz9ohXMdpO/06H4z5TQVTtIvOmxxqDqlpVh smDYXtxt3QFF1QIpXhVpDlP6vBCel8G4pGYwgXluFmz12anzzofliFbvTas3Gw== 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 4SWcPN5wmDz5sP; Thu, 16 Nov 2023 23:56:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AGNu8YF054314; Thu, 16 Nov 2023 23:56:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AGNu87Z054311; Thu, 16 Nov 2023 23:56:08 GMT (envelope-from git) Date: Thu, 16 Nov 2023 23:56:08 GMT Message-Id: <202311162356.3AGNu87Z054311@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: 0948d2a9cfea - stable/13 - nfsd: Avoid acquiring a vnode for some NFSv4 Readdir operations 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: 0948d2a9cfea5a469a9505fb314a6f9af38bb6fa Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=0948d2a9cfea5a469a9505fb314a6f9af38bb6fa commit 0948d2a9cfea5a469a9505fb314a6f9af38bb6fa Author: Rick Macklem AuthorDate: 2023-10-17 20:55:48 +0000 Commit: Rick Macklem CommitDate: 2023-11-16 23:54:20 +0000 nfsd: Avoid acquiring a vnode for some NFSv4 Readdir operations Without this patch, a NFSv4 Readdir operation acquires the vnode for each entry in the directory. If only the Type, Fileid, Mounted_on_fileid and ReaddirError attributes are requested by a client, acquiring the vnode is not necessary for non-directories. Directory vnodes must be acquired to check for server file system mount points. This patch avoids acquiring the vnode, as above, resulting in a 3-8% improvement in Readdir RPC RTT for some simple tests I did. Note that only non-rdirplus NFSv4 mounts will benefit from this change. Tested during a recent IETF NFSv4 Bakeathon testing event. (cherry picked from commit cd5edc7db261fb228be4044e6fdd38850eb4e9c4) --- sys/fs/nfsserver/nfs_nfsdport.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index e2a3ff7e3b93..05cebdd13f7d 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -117,6 +117,11 @@ extern int nfsrv_issuedelegs; extern int nfsrv_dolocallocks; extern struct nfsdevicehead nfsrv_devidhead; +/* Map d_type to vnode type. */ +static uint8_t dtype_to_vnode[DT_WHT + 1] = { VNON, VFIFO, VCHR, VNON, VDIR, + VNON, VBLK, VNON, VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON }; +#define NFS_DTYPETOVTYPE(t) ((t) <= DT_WHT ? dtype_to_vnode[(t)] : VNON) + static int nfsrv_createiovec(int, struct mbuf **, struct mbuf **, struct iovec **); static int nfsrv_createiovec_extpgs(int, int, struct mbuf **, @@ -2319,7 +2324,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram, caddr_t bpos0, bpos1; u_int64_t off, toff, verf; u_long *cookies = NULL, *cookiep; - nfsattrbit_t attrbits, rderrbits, savbits; + nfsattrbit_t attrbits, rderrbits, savbits, refbits; struct uio io; struct iovec iv; struct componentname cn; @@ -2370,9 +2375,20 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram, if (error) goto nfsmout; NFSSET_ATTRBIT(&savbits, &attrbits); + NFSSET_ATTRBIT(&refbits, &attrbits); NFSCLRNOTFILLABLE_ATTRBIT(&attrbits, nd); NFSZERO_ATTRBIT(&rderrbits); NFSSETBIT_ATTRBIT(&rderrbits, NFSATTRBIT_RDATTRERROR); + /* + * If these 4 bits are the only attributes requested by the + * client, they can be satisfied without acquiring the vnode + * for the file object unless it is a directory. + * This will be indicated by savbits being all 0s. + */ + NFSCLRBIT_ATTRBIT(&savbits, NFSATTRBIT_TYPE); + NFSCLRBIT_ATTRBIT(&savbits, NFSATTRBIT_FILEID); + NFSCLRBIT_ATTRBIT(&savbits, NFSATTRBIT_MOUNTEDONFILEID); + NFSCLRBIT_ATTRBIT(&savbits, NFSATTRBIT_RDATTRERROR); } else { NFSZERO_ATTRBIT(&attrbits); } @@ -2616,7 +2632,10 @@ again: new_mp = mp; mounted_on_fileno = (uint64_t)dp->d_fileno; if ((nd->nd_flag & ND_NFSV3) || - NFSNONZERO_ATTRBIT(&savbits)) { + NFSNONZERO_ATTRBIT(&savbits) || + dp->d_type == DT_UNKNOWN || + (dp->d_type == DT_DIR && + nfsrv_enable_crossmntpt != 0)) { if (nd->nd_flag & ND_NFSV4) refp = nfsv4root_getreferral(NULL, vp, dp->d_fileno); @@ -2754,6 +2773,11 @@ again: break; } } + } else if (NFSNONZERO_ATTRBIT(&attrbits)) { + /* Only need Type and/or Fileid. */ + VATTR_NULL(&nvap->na_vattr); + nvap->na_fileid = dp->d_fileno; + nvap->na_type = NFS_DTYPETOVTYPE(dp->d_type); } /* @@ -2785,7 +2809,7 @@ again: supports_nfsv4acls = 0; if (refp != NULL) { dirlen += nfsrv_putreferralattr(nd, - &savbits, refp, 0, + &refbits, refp, 0, &nd->nd_repstat); if (nd->nd_repstat) { if (nvp != NULL)