summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2014-04-20 22:19:00 +0000
committerrmacklem <rmacklem@FreeBSD.org>2014-04-20 22:19:00 +0000
commit4dfafb6abe5ba6cdfd95cd1ab115cdd7ad5ec279 (patch)
treece52f2db23d955bb770aa3cd3f8f611e582a8e80
parent0d6ccd58e0a71af3f2f27f598bd9d6b0a5efd80d (diff)
downloadFreeBSD-src-4dfafb6abe5ba6cdfd95cd1ab115cdd7ad5ec279.zip
FreeBSD-src-4dfafb6abe5ba6cdfd95cd1ab115cdd7ad5ec279.tar.gz
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. MFC after: 2 weeks
-rw-r--r--sys/fs/nfsclient/nfs_clcomsubs.c2
-rw-r--r--sys/fs/nfsclient/nfs_clrpcops.c16
2 files changed, 17 insertions, 1 deletions
diff --git a/sys/fs/nfsclient/nfs_clcomsubs.c b/sys/fs/nfsclient/nfs_clcomsubs.c
index db4f173..1fc7d1b 100644
--- a/sys/fs/nfsclient/nfs_clcomsubs.c
+++ b/sys/fs/nfsclient/nfs_clcomsubs.c
@@ -67,7 +67,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, },
diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index a691531..29bb9d2 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -2545,10 +2545,12 @@ nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, struct vattr *vap,
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);
@@ -2564,6 +2566,12 @@ nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, struct vattr *vap,
*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)
@@ -2577,6 +2585,14 @@ nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, struct vattr *vap,
}
if (!error)
error = nfscl_mtofh(nd, nfhpp, nnap, attrflagp);
+ if (!error) {
+ /* 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);
OpenPOWER on IntegriCloud