From owner-svn-src-all@FreeBSD.ORG Mon May 5 01:01:31 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 75284DC1; Mon, 5 May 2014 01:01:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6146214E8; Mon, 5 May 2014 01:01:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4511VoI031245; Mon, 5 May 2014 01:01:31 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4511Uip031242; Mon, 5 May 2014 01:01:30 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201405050101.s4511Uip031242@svn.freebsd.org> From: Rick Macklem Date: Mon, 5 May 2014 01:01:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r265339 - in stable/9/sys/fs: nfs nfsclient X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 May 2014 01:01:31 -0000 Author: rmacklem Date: Mon May 5 01:01:30 2014 New Revision: 265339 URL: http://svnweb.freebsd.org/changeset/base/265339 Log: MFC: r264672 Modify the Lookup RPC for NFSv4 so that it acquires directory attributes. This allows the client to cache directory names when they are looked up, reducing the Lookup RPC count by about 40% for software builds. Modified: stable/9/sys/fs/nfs/nfs_commonsubs.c stable/9/sys/fs/nfsclient/nfs_clcomsubs.c stable/9/sys/fs/nfsclient/nfs_clrpcops.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- stable/9/sys/fs/nfs/nfs_commonsubs.c Sun May 4 23:25:32 2014 (r265338) +++ stable/9/sys/fs/nfs/nfs_commonsubs.c Mon May 5 01:01:30 2014 (r265339) @@ -101,8 +101,8 @@ struct nfsv4_opflag nfsv4_opflag[NFSV4OP { 0, 1, 0, 0, LK_EXCLUSIVE }, /* Lock */ { 0, 1, 0, 0, LK_EXCLUSIVE }, /* LockT */ { 0, 1, 0, 0, LK_EXCLUSIVE }, /* LockU */ - { 1, 1, 0, 0, LK_EXCLUSIVE }, /* Lookup */ - { 1, 1, 0, 0, LK_EXCLUSIVE }, /* Lookupp */ + { 1, 2, 0, 0, LK_EXCLUSIVE }, /* Lookup */ + { 1, 2, 0, 0, LK_EXCLUSIVE }, /* Lookupp */ { 0, 1, 0, 0, LK_EXCLUSIVE }, /* NVerify */ { 1, 1, 0, 1, LK_EXCLUSIVE }, /* Open */ { 1, 1, 0, 0, LK_EXCLUSIVE }, /* OpenAttr */ Modified: stable/9/sys/fs/nfsclient/nfs_clcomsubs.c ============================================================================== --- stable/9/sys/fs/nfsclient/nfs_clcomsubs.c Sun May 4 23:25:32 2014 (r265338) +++ stable/9/sys/fs/nfsclient/nfs_clcomsubs.c Mon May 5 01:01:30 2014 (r265339) @@ -167,9 +167,18 @@ nfscl_reqstart(struct nfsrv_descript *nd if (nfsv4_opflag[nfsv4_opmap[procnum].op].needscfh==2){ NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(NFSV4OP_GETATTR); - NFSWCCATTR_ATTRBIT(&attrbits); + /* + * For Lookup Ops, we want all the directory + * attributes, so we can load the name cache. + */ + if (procnum == NFSPROC_LOOKUP || + procnum == NFSPROC_LOOKUPP) + NFSGETATTR_ATTRBIT(&attrbits); + else { + NFSWCCATTR_ATTRBIT(&attrbits); + nd->nd_flag |= ND_V4WCCATTR; + } (void) nfsrv_putattrbit(nd, &attrbits); - nd->nd_flag |= ND_V4WCCATTR; } NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); } Modified: stable/9/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- stable/9/sys/fs/nfsclient/nfs_clrpcops.c Sun May 4 23:25:32 2014 (r265338) +++ stable/9/sys/fs/nfsclient/nfs_clrpcops.c Mon May 5 01:01:30 2014 (r265339) @@ -1135,14 +1135,23 @@ nfsrpc_lookup(vnode_t dvp, char *name, i } if (nd->nd_flag & ND_NFSV3) error = nfscl_postop_attr(nd, dnap, dattrflagp, stuff); + else if ((nd->nd_flag & (ND_NFSV4 | ND_NOMOREDATA)) == + ND_NFSV4) { + /* Load the directory attributes. */ + error = nfsm_loadattr(nd, dnap); + if (error == 0) + *dattrflagp = 1; + } goto nfsmout; } if ((nd->nd_flag & (ND_NFSV4 | ND_NOMOREDATA)) == ND_NFSV4) { - NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - if (*(tl + 1)) { - nd->nd_flag |= ND_NOMOREDATA; + /* Load the directory attributes. */ + error = nfsm_loadattr(nd, dnap); + if (error != 0) goto nfsmout; - } + *dattrflagp = 1; + /* Skip over the Lookup and GetFH operation status values. */ + NFSM_DISSECT(tl, u_int32_t *, 4 * NFSX_UNSIGNED); } error = nfsm_getfh(nd, nfhpp); if (error) @@ -2566,14 +2575,6 @@ nfsrpc_readdir(vnode_t vp, struct uio *u * Joy, oh joy. For V4 we get to hand craft '.' and '..'. */ if (uiop->uio_offset == 0) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 - error = VOP_GETATTR(vp, &nfsva.na_vattr, cred); -#else - error = VOP_GETATTR(vp, &nfsva.na_vattr, cred, p); -#endif - if (error) - return (error); - dotfileid = nfsva.na_fileid; NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, vp); NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(NFSV4OP_GETFH); @@ -2582,9 +2583,16 @@ nfsrpc_readdir(vnode_t vp, struct uio *u error = nfscl_request(nd, vp, p, cred, stuff); if (error) return (error); + dotfileid = 0; /* Fake out the compiler. */ + if ((nd->nd_flag & ND_NOMOREDATA) == 0) { + error = nfsm_loadattr(nd, &nfsva); + if (error != 0) + goto nfsmout; + dotfileid = nfsva.na_fileid; + } if (nd->nd_repstat == 0) { - NFSM_DISSECT(tl, u_int32_t *, 3*NFSX_UNSIGNED); - len = fxdr_unsigned(int, *(tl + 2)); + NFSM_DISSECT(tl, u_int32_t *, 5 * NFSX_UNSIGNED); + len = fxdr_unsigned(int, *(tl + 4)); if (len > 0 && len <= NFSX_V4FHMAX) error = nfsm_advance(nd, NFSM_RNDUP(len), -1); else @@ -2993,15 +3001,6 @@ nfsrpc_readdirplus(vnode_t vp, struct ui * Joy, oh joy. For V4 we get to hand craft '.' and '..'. */ if (uiop->uio_offset == 0) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 - error = VOP_GETATTR(vp, &nfsva.na_vattr, cred); -#else - error = VOP_GETATTR(vp, &nfsva.na_vattr, cred, p); -#endif - if (error) - return (error); - dctime = nfsva.na_ctime; - dotfileid = nfsva.na_fileid; NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, vp); NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(NFSV4OP_GETFH); @@ -3010,9 +3009,17 @@ nfsrpc_readdirplus(vnode_t vp, struct ui error = nfscl_request(nd, vp, p, cred, stuff); if (error) return (error); + dotfileid = 0; /* Fake out the compiler. */ + if ((nd->nd_flag & ND_NOMOREDATA) == 0) { + error = nfsm_loadattr(nd, &nfsva); + if (error != 0) + goto nfsmout; + dctime = nfsva.na_ctime; + dotfileid = nfsva.na_fileid; + } if (nd->nd_repstat == 0) { - NFSM_DISSECT(tl, u_int32_t *, 3*NFSX_UNSIGNED); - len = fxdr_unsigned(int, *(tl + 2)); + NFSM_DISSECT(tl, u_int32_t *, 5 * NFSX_UNSIGNED); + len = fxdr_unsigned(int, *(tl + 4)); if (len > 0 && len <= NFSX_V4FHMAX) error = nfsm_advance(nd, NFSM_RNDUP(len), -1); else