1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-26 11:47:31 +00:00

Modify the NFSv4 client open/create RPC so that it acquires

post-open/create directory attributes. This allows the RPC to
name cache the newly created file and reduces the lookup RPC
count by about 10% for software builds.

MFC after:	2 weeks
This commit is contained in:
Rick Macklem 2014-04-19 19:40:20 +00:00
parent ad6c0150c0
commit de1a42bd0c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=264681
2 changed files with 17 additions and 5 deletions

View File

@ -66,7 +66,7 @@ static struct {
{ NFSV4OP_READLINK, 2, "Readlink", 8, }, { NFSV4OP_READLINK, 2, "Readlink", 8, },
{ NFSV4OP_READ, 1, "Read", 4, }, { NFSV4OP_READ, 1, "Read", 4, },
{ NFSV4OP_WRITE, 2, "Write", 5, }, { NFSV4OP_WRITE, 2, "Write", 5, },
{ NFSV4OP_OPEN, 3, "Open", 4, }, { NFSV4OP_OPEN, 5, "Open", 4, },
{ NFSV4OP_CREATE, 3, "Create", 6, }, { NFSV4OP_CREATE, 3, "Create", 6, },
{ NFSV4OP_CREATE, 1, "Create", 6, }, { NFSV4OP_CREATE, 1, "Create", 6, },
{ NFSV4OP_CREATE, 3, "Create", 6, }, { NFSV4OP_CREATE, 3, "Create", 6, },

View File

@ -1956,6 +1956,7 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap,
struct nfsmount *nmp; struct nfsmount *nmp;
nmp = VFSTONFS(dvp->v_mount); nmp = VFSTONFS(dvp->v_mount);
np = VTONFS(dvp);
*unlockedp = 0; *unlockedp = 0;
*nfhpp = NULL; *nfhpp = NULL;
*dpp = NULL; *dpp = NULL;
@ -2005,17 +2006,22 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap,
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(NFSV4OPEN_CLAIMNULL); *tl = txdr_unsigned(NFSV4OPEN_CLAIMNULL);
(void) nfsm_strtom(nd, name, namelen); (void) nfsm_strtom(nd, name, namelen);
/* Get the new file's handle and attributes. */
NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(NFSV4OP_GETFH); *tl++ = txdr_unsigned(NFSV4OP_GETFH);
*tl = txdr_unsigned(NFSV4OP_GETATTR); *tl = txdr_unsigned(NFSV4OP_GETATTR);
NFSGETATTR_ATTRBIT(&attrbits); NFSGETATTR_ATTRBIT(&attrbits);
(void) nfsrv_putattrbit(nd, &attrbits); (void) nfsrv_putattrbit(nd, &attrbits);
/* Get the directory's post-op attributes. */
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(NFSV4OP_PUTFH);
(void) nfsm_fhtom(nd, np->n_fhp->nfh_fh, np->n_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); error = nfscl_request(nd, dvp, p, cred, dstuff);
if (error) if (error)
return (error); return (error);
error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff);
if (error)
goto nfsmout;
NFSCL_INCRSEQID(owp->nfsow_seqid, nd); NFSCL_INCRSEQID(owp->nfsow_seqid, nd);
if (nd->nd_repstat == 0) { if (nd->nd_repstat == 0) {
NFSM_DISSECT(tl, u_int32_t *, NFSX_STATEID + NFSM_DISSECT(tl, u_int32_t *, NFSX_STATEID +
@ -2087,6 +2093,13 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap,
error = nfscl_mtofh(nd, nfhpp, nnap, attrflagp); error = nfscl_mtofh(nd, nfhpp, nnap, attrflagp);
if (error) if (error)
goto nfsmout; goto nfsmout;
/* 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)
goto nfsmout;
*dattrflagp = 1;
if (dp != NULL && *attrflagp) { if (dp != NULL && *attrflagp) {
dp->nfsdl_change = nnap->na_filerev; dp->nfsdl_change = nnap->na_filerev;
dp->nfsdl_modtime = nnap->na_mtime; dp->nfsdl_modtime = nnap->na_mtime;
@ -2130,7 +2143,6 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap,
if ((rflags & NFSV4OPEN_RESULTCONFIRM) && if ((rflags & NFSV4OPEN_RESULTCONFIRM) &&
(owp->nfsow_clp->nfsc_flags & NFSCLFLAGS_GOTDELEG) && (owp->nfsow_clp->nfsc_flags & NFSCLFLAGS_GOTDELEG) &&
!error && dp == NULL) { !error && dp == NULL) {
np = VTONFS(dvp);
do { do {
ret = nfsrpc_openrpc(VFSTONFS(vnode_mount(dvp)), dvp, ret = nfsrpc_openrpc(VFSTONFS(vnode_mount(dvp)), dvp,
np->n_fhp->nfh_fh, np->n_fhp->nfh_len, np->n_fhp->nfh_fh, np->n_fhp->nfh_len,