Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 May 2014 20:48:36 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r265389 - stable/9/sys/fs/nfsclient
Message-ID:  <201405052048.s45KmaYY066760@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon May  5 20:48:36 2014
New Revision: 265389
URL: http://svnweb.freebsd.org/changeset/base/265389

Log:
  MFC: r264705, r264749
  Modify the NFSv4 client create/mkdir RPC so that it acquires
  post-create/mkdir directory attributes. This allows the RPC to
  name cache the newly created directory and reduces the lookup RPC
  count for applications creating a lot of directories.

Modified:
  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/nfsclient/nfs_clcomsubs.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clcomsubs.c	Mon May  5 20:35:35 2014	(r265388)
+++ stable/9/sys/fs/nfsclient/nfs_clcomsubs.c	Mon May  5 20:48:36 2014	(r265389)
@@ -66,7 +66,7 @@ static struct {
 	{ NFSV4OP_READ, 1, "Read", 4, },
 	{ NFSV4OP_WRITE, 2, "Write", 5, },
 	{ NFSV4OP_OPEN, 5, "Open", 4, },
-	{ NFSV4OP_CREATE, 3, "Create", 6, },
+	{ NFSV4OP_CREATE, 5, "Create", 6, },
 	{ NFSV4OP_CREATE, 1, "Create", 6, },
 	{ NFSV4OP_CREATE, 3, "Create", 6, },
 	{ NFSV4OP_REMOVE, 1, "Remove", 6, },

Modified: stable/9/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clrpcops.c	Mon May  5 20:35:35 2014	(r265388)
+++ stable/9/sys/fs/nfsclient/nfs_clrpcops.c	Mon May  5 20:48:36 2014	(r265389)
@@ -2409,10 +2409,12 @@ nfsrpc_mkdir(vnode_t dvp, char *name, in
 	struct nfsrv_descript nfsd, *nd = &nfsd;
 	nfsattrbit_t attrbits;
 	int error = 0;
+	struct nfsfh *fhp;
 
 	*nfhpp = NULL;
 	*attrflagp = 0;
 	*dattrflagp = 0;
+	fhp = VTONFS(dvp)->n_fhp;
 	if (namelen > NFS_MAXNAMLEN)
 		return (ENAMETOOLONG);
 	NFSCL_REQSTART(nd, NFSPROC_MKDIR, dvp);
@@ -2428,6 +2430,12 @@ nfsrpc_mkdir(vnode_t dvp, char *name, in
 		*tl++ = txdr_unsigned(NFSV4OP_GETFH);
 		*tl = txdr_unsigned(NFSV4OP_GETATTR);
 		(void) nfsrv_putattrbit(nd, &attrbits);
+		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
+		*tl = txdr_unsigned(NFSV4OP_PUTFH);
+		(void) nfsm_fhtom(nd, fhp->nfh_fh, fhp->nfh_len, 0);
+		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
+		*tl = txdr_unsigned(NFSV4OP_GETATTR);
+		(void) nfsrv_putattrbit(nd, &attrbits);
 	}
 	error = nfscl_request(nd, dvp, p, cred, dstuff);
 	if (error)
@@ -2441,6 +2449,14 @@ nfsrpc_mkdir(vnode_t dvp, char *name, in
 		}
 		if (!error)
 			error = nfscl_mtofh(nd, nfhpp, nnap, attrflagp);
+		if (error == 0 && (nd->nd_flag & ND_NFSV4) != 0) {
+			/* Get rid of the PutFH and Getattr status values. */
+			NFSM_DISSECT(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
+			/* Load the directory attributes. */
+			error = nfsm_loadattr(nd, dnap);
+			if (error == 0)
+				*dattrflagp = 1;
+		}
 	}
 	if ((nd->nd_flag & ND_NFSV3) && !error)
 		error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405052048.s45KmaYY066760>