From nobody Thu Nov 16 23:48:11 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 4SWcDC3yVGz51FSL; Thu, 16 Nov 2023 23:48:11 +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 4SWcDC3VZcz3LW3; Thu, 16 Nov 2023 23:48:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700178491; 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=dRGTGGsYJrv3BC0/Fc+KbPF5xK4pN7sW3KXr+6/Wrvc=; b=ZQFnxJKfLmh/cJGe06Zpf9Vdj3VXvb55hBH5cQrkLJq6z3keSu6fp/xNiqKEREKNSbkhCl lkql6OxLgr72Vd6JXnjO/TFlt6Jkwbp7F6hX9zvx2+Gd+53G+4jvCDctrBqe7pFBlJcTnl A/0eKaBiOdWLwvI0JorjJ2zPx/7iGbTzdr3Koliq7sG9U7aAviqkChX4mf/WXSZHwQy2A9 pm3pe6KkFQMJQ1KD44X3uv1aj88X8DKouG4TL9XzwSfHtqQAeoHW/jPTPqaQ71Oix2Ot08 vuI10KmhVxUVB61bee/GpbRoxmANkZ26pB9w1T3BOZJD/UpyjEmc71fJocrN/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700178491; 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=dRGTGGsYJrv3BC0/Fc+KbPF5xK4pN7sW3KXr+6/Wrvc=; b=I5SbFLb4OgUlrx/To0GI2UuHxxl2sMm545t2VIXPeJIHmltp8AzXkaMTwtJU1wITm+tRRJ f3oFh6wTZ6xpqNj3vi026SdcgZp9TGLzCmcQtdKwwQPm4HHl2JoSDIJnXUMcj7R/YYnneO xfD5JRsjBVYvvHiWA3+wddTsFE5X523rYswniWp8QdxSKH6818HPYuSGGChuL4eTbRhaaO OLtBKmLoo5c9enCx2SSax2n1gZNM5wbVo/2GGFVickYfGjRF+FthpeB1faoHs+2p3RL8AT uM0bzZXJfH6L8/+Cd7UFleSgSta8O7xJXUfWQhEiR4Hw+I1w32mgBKuVyy54+g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700178491; a=rsa-sha256; cv=none; b=o8yJgiQSF+xvtspP4rzxhtkubh9OpyvP/rkLYNth6FsiNGhLSuOP0VjJPA1utJogpJ8vjJ GaeMY9ecxaWLSIzmEg+d7madHhZBEBYB5xX1ppTs6Srl9UaqnwUY5DrBTbtEjB3jdW2uF7 3GJ5jGNYuU7X0JenSUH5g99qE+qQtTaByheKWryo182yPIeGJMnH6yjR8imDndSdddjho3 ieinJ8EDSNxFvPG1NoXe5139TMcI5u8IdPV2GV5MxutAtBHO6x2cqOzvCRqIxIvsK/flP2 SW5dW5R0QYaChyrR8ni00XVb7sFIvo5CxGRcSxCdT1760zkayExhKLRFCiqXPw== 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 4SWcDC2ZxRz53M; Thu, 16 Nov 2023 23:48:11 +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 3AGNmBl9037245; Thu, 16 Nov 2023 23:48:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AGNmBfG037242; Thu, 16 Nov 2023 23:48:11 GMT (envelope-from git) Date: Thu, 16 Nov 2023 23:48:11 GMT Message-Id: <202311162348.3AGNmBfG037242@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: f40c9502c438 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: f40c9502c438d230a06157ec7f9be1c21ae46541 Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f40c9502c438d230a06157ec7f9be1c21ae46541 commit f40c9502c438d230a06157ec7f9be1c21ae46541 Author: Rick Macklem AuthorDate: 2023-10-17 20:55:48 +0000 Commit: Rick Macklem CommitDate: 2023-11-16 23:46:17 +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 570ae653e06c..776d5c50861c 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 **, @@ -2310,7 +2315,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram, caddr_t bpos0, bpos1; u_int64_t off, toff, verf __unused; uint64_t *cookies = NULL, *cookiep; - nfsattrbit_t attrbits, rderrbits, savbits; + nfsattrbit_t attrbits, rderrbits, savbits, refbits; struct uio io; struct iovec iv; struct componentname cn; @@ -2361,9 +2366,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); } @@ -2606,7 +2622,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); @@ -2743,6 +2762,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); } /* @@ -2774,7 +2798,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)