diff options
author | dyson <dyson@FreeBSD.org> | 1997-09-21 04:24:27 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1997-09-21 04:24:27 +0000 |
commit | e64b1984f97c6d987d7d36b61a3afe5028a08312 (patch) | |
tree | 325bcf17de3aad0383fb86548872026a7c3d2599 /sys/nfsserver | |
parent | 1419fcb42b4e1e5a73f4574739f4c232fde357e2 (diff) | |
download | FreeBSD-src-e64b1984f97c6d987d7d36b61a3afe5028a08312.zip FreeBSD-src-e64b1984f97c6d987d7d36b61a3afe5028a08312.tar.gz |
Change the M_NAMEI allocations to use the zone allocator. This change
plus the previous changes to use the zone allocator decrease the useage
of malloc by half. The Zone allocator will be upgradeable to be able
to use per CPU-pools, and has more intelligent usage of SPLs. Additionally,
it has reasonable stats gathering capabilities, while making most calls
inline.
Diffstat (limited to 'sys/nfsserver')
-rw-r--r-- | sys/nfsserver/nfs_serv.c | 44 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsubs.c | 21 |
2 files changed, 33 insertions, 32 deletions
diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index b276f19..d275143 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94 - * $Id: nfs_serv.c,v 1.49 1997/09/10 19:52:25 phk Exp $ + * $Id: nfs_serv.c,v 1.50 1997/09/10 20:22:28 phk Exp $ */ /* @@ -448,7 +448,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) nqsrv_getl(ndp->ni_startdir, ND_READ); vrele(ndp->ni_startdir); - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); vp = ndp->ni_vp; bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; @@ -1460,7 +1460,7 @@ nfsrv_create(nfsd, slp, procp, mrq) error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap); if (!error) { nfsrv_object_create(nd.ni_vp); - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); if (exclusive_flag) { exclusive_flag = 0; VATTR_NULL(vap); @@ -1477,7 +1477,7 @@ nfsrv_create(nfsd, slp, procp, mrq) if (vap->va_type != VFIFO && (error = suser(cred, (u_short *)0))) { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); nfsm_reply(0); @@ -1494,11 +1494,11 @@ nfsrv_create(nfsd, slp, procp, mrq) nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = cred; if (error = lookup(&nd)) { - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); nfsm_reply(0); } nfsrv_object_create(nd.ni_vp); - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); if (nd.ni_cnd.cn_flags & ISSYMLINK) { vrele(nd.ni_dvp); vput(nd.ni_vp); @@ -1508,7 +1508,7 @@ nfsrv_create(nfsd, slp, procp, mrq) } } else { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); error = ENXIO; @@ -1516,7 +1516,7 @@ nfsrv_create(nfsd, slp, procp, mrq) vp = nd.ni_vp; } else { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); vp = nd.ni_vp; if (nd.ni_dvp == vp) vrele(nd.ni_dvp); @@ -1571,7 +1571,7 @@ nfsmout: vrele(dirp); if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); } VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) @@ -1635,7 +1635,7 @@ nfsrv_mknod(nfsd, slp, procp, mrq) vtyp = nfsv3tov_type(*tl); if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); error = NFSERR_BADTYPE; VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); @@ -1655,7 +1655,7 @@ nfsrv_mknod(nfsd, slp, procp, mrq) */ if (nd.ni_vp) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); error = EEXIST; VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); @@ -1667,11 +1667,11 @@ nfsrv_mknod(nfsd, slp, procp, mrq) nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap); if (!error) - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); } else { if (vtyp != VFIFO && (error = suser(cred, (u_short *)0))) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); goto out; @@ -1686,7 +1686,7 @@ nfsrv_mknod(nfsd, slp, procp, mrq) nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = procp->p_ucred; error = lookup(&nd); - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); if (error) goto out; if (nd.ni_cnd.cn_flags & ISSYMLINK) { @@ -1720,7 +1720,7 @@ nfsmout: vrele(dirp); if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); } VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) @@ -1989,7 +1989,7 @@ out: error = 0; } vrele(tond.ni_startdir); - FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, tond.ni_cnd.cn_pnbuf); out1: if (fdirp) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); @@ -2000,7 +2000,7 @@ out1: vrele(tdirp); } vrele(fromnd.ni_startdir); - FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, fromnd.ni_cnd.cn_pnbuf); nfsm_reply(2 * NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); @@ -2015,11 +2015,11 @@ nfsmout: vrele(tdirp); if (tond.ni_cnd.cn_nameiop) { vrele(tond.ni_startdir); - FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, tond.ni_cnd.cn_pnbuf); } if (fromnd.ni_cnd.cn_nameiop) { vrele(fromnd.ni_startdir); - FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, fromnd.ni_cnd.cn_pnbuf); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); @@ -2199,7 +2199,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) *(pathcp + len2) = '\0'; if (nd.ni_vp) { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); @@ -2232,7 +2232,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) } } else vrele(nd.ni_startdir); - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); } out: if (pathcp) @@ -2253,7 +2253,7 @@ out: nfsmout: if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + zfree(namei_zone, nd.ni_cnd.cn_pnbuf); } if (dirp) vrele(dirp); diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index e7b5340..4367794 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94 - * $Id: nfs_subs.c,v 1.41 1997/08/16 19:15:59 wollman Exp $ + * $Id: nfs_subs.c,v 1.42 1997/09/10 19:52:26 phk Exp $ */ /* @@ -1444,7 +1444,8 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) struct componentname *cnp = &ndp->ni_cnd; *retdirp = (struct vnode *)0; - MALLOC(cnp->cn_pnbuf, char *, len + 1, M_NAMEI, M_WAITOK); + cnp->cn_pnbuf = zalloc(namei_zone); + /* * Copy the name from the mbuf list to ndp->ni_pnbuf * and set the various ndp fields appropriately. @@ -1506,7 +1507,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * Oh joy. For WebNFS, handle those pesky '%' escapes, * and the 'native path' indicator. */ - MALLOC(cp, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); + cp = zalloc(namei_zone); fromcp = cnp->cn_pnbuf; tocp = cp; if ((unsigned char)*fromcp >= WEBNFS_SPECCHAR_START) { @@ -1524,7 +1525,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) */ default: error = EIO; - FREE(cp, M_NAMEI); + zfree(namei_zone, cp); goto out; } } @@ -1540,14 +1541,14 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) continue; } else { error = ENOENT; - FREE(cp, M_NAMEI); + zfree(namei_zone, cp); goto out; } } else *tocp++ = *fromcp++; } *tocp = '\0'; - FREE(cnp->cn_pnbuf, M_NAMEI); + zfree(namei_zone, cnp->cn_pnbuf); cnp->cn_pnbuf = cp; } @@ -1601,7 +1602,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) break; } if (ndp->ni_pathlen > 1) - MALLOC(cp, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); + cp = zalloc(namei_zone); else cp = cnp->cn_pnbuf; aiov.iov_base = cp; @@ -1617,7 +1618,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) if (error) { badlink: if (ndp->ni_pathlen > 1) - FREE(cp, M_NAMEI); + zfree(namei_zone, cp); break; } linklen = MAXPATHLEN - auio.uio_resid; @@ -1631,7 +1632,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) } if (ndp->ni_pathlen > 1) { bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen); - FREE(cnp->cn_pnbuf, M_NAMEI); + zfree(namei_zone, cnp->cn_pnbuf); cnp->cn_pnbuf = cp; } else cnp->cn_pnbuf[linklen] = '\0'; @@ -1649,7 +1650,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) } } out: - FREE(cnp->cn_pnbuf, M_NAMEI); + zfree(namei_zone, cnp->cn_pnbuf); return (error); } |