diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2004-05-14 04:00:35 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2004-05-14 04:00:35 +0000 |
commit | fca2cf71cc88b832f5e93f0288867997cb0d35d4 (patch) | |
tree | b3b384460ab9208645ad0e2923d26d70668c0916 | |
parent | e517eaa484ed1d99ebecdc738e49a7d3d93aec3c (diff) |
use pool for namei pathbuf. testing ok millert@ tdeval@
-rw-r--r-- | sys/isofs/cd9660/cd9660_vnops.c | 13 | ||||
-rw-r--r-- | sys/kern/exec_script.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 13 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 5 | ||||
-rw-r--r-- | sys/kern/vfs_init.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_lookup.c | 21 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 11 | ||||
-rw-r--r-- | sys/miscfs/union/union_subr.c | 9 | ||||
-rw-r--r-- | sys/nfs/nfs_serv.c | 47 | ||||
-rw-r--r-- | sys/nfs/nfs_subs.c | 7 | ||||
-rw-r--r-- | sys/nfs/nfs_vnops.c | 21 | ||||
-rw-r--r-- | sys/sys/malloc.h | 6 | ||||
-rw-r--r-- | sys/sys/namei.h | 4 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vnops.c | 12 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_extattr.c | 9 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 19 | ||||
-rw-r--r-- | sys/xfs/xfs_vnodeops-bsd.c | 6 |
17 files changed, 120 insertions, 98 deletions
diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 5bf3fcecc97..8fe48179ddd 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vnops.c,v 1.29 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: cd9660_vnops.c,v 1.30 2004/05/14 04:00:34 tedu Exp $ */ /* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */ /*- @@ -50,6 +50,7 @@ #include <sys/mount.h> #include <sys/vnode.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/dirent.h> #include <sys/ioctl.h> #include <sys/ioccom.h> @@ -97,7 +98,7 @@ cd9660_mknod(ndp, vap, cred, p) struct proc *p; { #ifndef ISODEVMAP - free(ndp->ni_pnbuf, M_NAMEI); + pool_put(i&namei_pool, ndp->ni_pnbuf); vput(ndp->ni_dvp); vput(ndp->ni_vp); return (EINVAL); @@ -113,7 +114,7 @@ cd9660_mknod(ndp, vap, cred, p) if (ip->i_mnt->iso_ftype != ISO_FTYPE_RRIP || vap->va_type != vp->v_type || (vap->va_type != VCHR && vap->va_type != VBLK)) { - free(ndp->ni_pnbuf, M_NAMEI); + pool_put(&namei_pool, ndp->ni_pnbuf); vput(ndp->ni_dvp); vput(ndp->ni_vp); return (EINVAL); @@ -795,7 +796,7 @@ cd9660_readlink(v) uio->uio_iov->iov_len >= MAXPATHLEN) symname = uio->uio_iov->iov_base; else - MALLOC(symname, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); + symname = pool_get(&namei_pool, PR_WAITOK); /* * Ok, we just gathering a symbolic name in SL record. @@ -803,7 +804,7 @@ cd9660_readlink(v) if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) { if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iov->iov_len < MAXPATHLEN) - FREE(symname, M_NAMEI); + pool_put(&namei_pool, symname); brelse(bp); return (EINVAL); } @@ -818,7 +819,7 @@ cd9660_readlink(v) if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iov->iov_len < MAXPATHLEN) { error = uiomove(symname, symlen, uio); - FREE(symname, M_NAMEI); + pool_put(&namei_pool, symname); return (error); } uio->uio_resid -= symlen; diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c index 702ea6345ac..4ad3847350a 100644 --- a/sys/kern/exec_script.c +++ b/sys/kern/exec_script.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_script.c,v 1.18 2003/05/03 21:14:59 deraadt Exp $ */ +/* $OpenBSD: exec_script.c,v 1.19 2004/05/14 04:00:33 tedu Exp $ */ /* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */ /* @@ -35,6 +35,7 @@ #include <sys/systm.h> #include <sys/proc.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/vnode.h> #include <sys/namei.h> #include <sys/file.h> @@ -245,7 +246,7 @@ check_shell: vn_close(scriptvp, FREAD, p->p_ucred, p); /* free the old pathname buffer */ - FREE(oldpnbuf, M_NAMEI); + pool_put(&namei_pool, oldpnbuf); epp->ep_flags |= (EXEC_HASARGL | EXEC_SKIPARG); epp->ep_fa = shellargp; @@ -278,7 +279,7 @@ fail: } else vn_close(scriptvp, FREAD, p->p_ucred, p); - FREE(epp->ep_ndp->ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, epp->ep_ndp->ni_cnd.cn_pnbuf); /* free the fake arg list, because we're not returning it */ if ((tmpsap = shellargp) != NULL) { diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 49478829bf2..27018f6c610 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.84 2004/03/12 09:32:55 tedu Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.85 2004/05/14 04:00:33 tedu Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -40,6 +40,7 @@ #include <sys/proc.h> #include <sys/mount.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/namei.h> #include <sys/vnode.h> #include <sys/file.h> @@ -209,7 +210,7 @@ bad2: * close the vnode, free the pathname buf, and punt. */ vn_close(vp, FREAD, p->p_ucred, p); - FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, ndp->ni_cnd.cn_pnbuf); return (error); bad1: @@ -217,7 +218,7 @@ bad1: * free the namei pathname buffer, and put the vnode * (which we don't yet have open). */ - FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, ndp->ni_cnd.cn_pnbuf); vput(vp); return (error); } @@ -564,7 +565,7 @@ sys_execve(p, v, retval) uvm_km_free_wakeup(exec_map, (vaddr_t) argp, NCARGS); - FREE(nid.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nid.ni_cnd.cn_pnbuf); vn_close(pack.ep_vp, FREAD, cred, p); /* @@ -637,7 +638,7 @@ bad: FREE(pack.ep_emul_arg, M_TEMP); /* close and put the exec'd file */ vn_close(pack.ep_vp, FREAD, cred, p); - FREE(nid.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nid.ni_cnd.cn_pnbuf); uvm_km_free_wakeup(exec_map, (vaddr_t) argp, NCARGS); freehdr: @@ -657,7 +658,7 @@ exec_abort: FREE(pack.ep_interp, M_TEMP); if (pack.ep_emul_arg != NULL) FREE(pack.ep_emul_arg, M_TEMP); - FREE(nid.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nid.ni_cnd.cn_pnbuf); vn_close(pack.ep_vp, FREAD, cred, p); uvm_km_free_wakeup(exec_map, (vaddr_t) argp, NCARGS); diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 8c69b6685c0..d0f923ee2d3 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_default.c,v 1.23 2004/04/25 03:21:19 jolan Exp $ */ +/* $OpenBSD: vfs_default.c,v 1.24 2004/05/14 04:00:33 tedu Exp $ */ /* * Portions of this code are: @@ -44,6 +44,7 @@ #include <sys/vnode.h> #include <sys/namei.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/event.h> #include <miscfs/specfs/specdev.h> @@ -140,7 +141,7 @@ vop_generic_abortop(v) } */ *ap = v; if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF) - FREE(ap->a_cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, ap->a_cnp->cn_pnbuf); return (0); } diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index ec5d3e2592f..39fed135549 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_init.c,v 1.16 2003/08/18 01:51:57 tedu Exp $ */ +/* $OpenBSD: vfs_init.c,v 1.17 2004/05/14 04:00:33 tedu Exp $ */ /* $NetBSD: vfs_init.c,v 1.6 1996/02/09 19:00:58 christos Exp $ */ /* @@ -48,6 +48,7 @@ #include <sys/buf.h> #include <sys/errno.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/systm.h> /* @@ -230,6 +231,8 @@ vfs_op_init() */ struct vattr va_null; +struct pool namei_pool; + /* * Initialize the vnode structures and initialize each file system type. */ @@ -240,6 +243,9 @@ vfsinit() struct vfsconf *vfsconflist; int vfsconflistlen; + pool_init(&namei_pool, MAXPATHLEN, 0, 0, 0, "namei", + &pool_allocator_nointr); + /* * Initialize the vnode table */ diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 96bcf0fc310..87a73ff1c1d 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_lookup.c,v 1.26 2003/10/08 16:30:01 sturm Exp $ */ +/* $OpenBSD: vfs_lookup.c,v 1.27 2004/05/14 04:00:33 tedu Exp $ */ /* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */ /* @@ -46,6 +46,7 @@ #include <sys/mount.h> #include <sys/errno.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/filedesc.h> #include <sys/proc.h> #include <sys/hash.h> @@ -106,7 +107,7 @@ namei(ndp) * name into the buffer. */ if ((cnp->cn_flags & HASBUF) == 0) - MALLOC(cnp->cn_pnbuf, caddr_t, MAXPATHLEN, M_NAMEI, M_WAITOK); + cnp->cn_pnbuf = pool_get(&namei_pool, PR_WAITOK); if (ndp->ni_segflg == UIO_SYSSPACE) error = copystr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, &ndp->ni_pathlen); @@ -121,7 +122,7 @@ namei(ndp) error = ENOENT; if (error) { - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); ndp->ni_vp = NULL; return (error); } @@ -172,13 +173,13 @@ namei(ndp) for (;;) { if (!dp->v_mount) { /* Give up if the directory is no longer mounted */ - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); return (ENOENT); } cnp->cn_nameptr = cnp->cn_pnbuf; ndp->ni_startdir = dp; if ((error = lookup(ndp)) != 0) { - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); return (error); } /* @@ -186,7 +187,7 @@ namei(ndp) */ if ((cnp->cn_flags & ISSYMLINK) == 0) { if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0) - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); else cnp->cn_flags |= HASBUF; return (0); @@ -198,7 +199,7 @@ namei(ndp) break; } if (ndp->ni_pathlen > 1) - MALLOC(cp, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); + cp = pool_get(&namei_pool, PR_WAITOK); else cp = cnp->cn_pnbuf; aiov.iov_base = cp; @@ -214,7 +215,7 @@ namei(ndp) if (error) { badlink: if (ndp->ni_pathlen > 1) - FREE(cp, M_NAMEI); + pool_put(&namei_pool, cp); break; } linklen = MAXPATHLEN - auio.uio_resid; @@ -224,7 +225,7 @@ badlink: } if (ndp->ni_pathlen > 1) { bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen); - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); cnp->cn_pnbuf = cp; } else cnp->cn_pnbuf[linklen] = '\0'; @@ -240,7 +241,7 @@ badlink: VREF(dp); } } - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vrele(ndp->ni_dvp); vput(ndp->ni_vp); ndp->ni_vp = NULL; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 5c3a10d593e..37708a02b27 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.110 2004/05/10 22:36:21 pedro Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.111 2004/05/14 04:00:33 tedu Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -49,6 +49,7 @@ #include <sys/proc.h> #include <sys/uio.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/dirent.h> #include <sys/extattr.h> @@ -1424,7 +1425,7 @@ sys_symlink(p, v, retval) int error; struct nameidata nd; - MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); + path = pool_get(&namei_pool, PR_WAITOK); error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL); if (error) goto out; @@ -1446,7 +1447,7 @@ sys_symlink(p, v, retval) VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path); out: - FREE(path, M_NAMEI); + pool_put(&namei_pool, path); return (error); } @@ -2417,11 +2418,11 @@ out: vrele(fvp); } vrele(tond.ni_startdir); - FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, tond.ni_cnd.cn_pnbuf); out1: if (fromnd.ni_startdir) vrele(fromnd.ni_startdir); - FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, fromnd.ni_cnd.cn_pnbuf); if (error == -1) return (0); return (error); diff --git a/sys/miscfs/union/union_subr.c b/sys/miscfs/union/union_subr.c index c1ec282f2a3..0c9ce325a68 100644 --- a/sys/miscfs/union/union_subr.c +++ b/sys/miscfs/union/union_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: union_subr.c,v 1.16 2004/04/25 19:46:40 tedu Exp $ */ +/* $OpenBSD: union_subr.c,v 1.17 2004/05/14 04:00:34 tedu Exp $ */ /* $NetBSD: union_subr.c,v 1.41 2001/11/10 13:33:45 lukem Exp $ */ /* @@ -45,6 +45,7 @@ #include <sys/vnode.h> #include <sys/namei.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/file.h> #include <sys/filedesc.h> #include <sys/queue.h> @@ -799,7 +800,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen) cn->cn_namelen = pathlen; if ((cn->cn_namelen + 1) > MAXPATHLEN) return (ENAMETOOLONG); - cn->cn_pnbuf = malloc(cn->cn_namelen+1, M_NAMEI, M_WAITOK); + cn->cn_pnbuf = pool_get(&namei_pool, PR_WAITOK); memcpy(cn->cn_pnbuf, path, cn->cn_namelen); cn->cn_pnbuf[cn->cn_namelen] = '\0'; @@ -820,7 +821,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen) if (!error) vrele(dvp); else { - free(cn->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cn->cn_pnbuf); cn->cn_pnbuf = 0; } @@ -970,7 +971,7 @@ union_vn_create(vpp, un, p) cn.cn_namelen = strlen(un->un_path); if ((cn.cn_namelen + 1) > MAXPATHLEN) return (ENAMETOOLONG); - cn.cn_pnbuf = malloc(cn.cn_namelen+1, M_NAMEI, M_WAITOK); + cn.cn_pnbuf = pool_get(&namei_pool, PR_WAITOK); memcpy(cn.cn_pnbuf, un->un_path, cn.cn_namelen+1); cn.cn_nameiop = CREATE; cn.cn_flags = (LOCKPARENT|HASBUF|SAVENAME|SAVESTART|ISLASTCN); diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index a0cdc8349f7..928eb898aec 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.36 2003/08/15 20:32:20 tedu Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.37 2004/05/14 04:00:34 tedu Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -68,6 +68,7 @@ #include <sys/dirent.h> #include <sys/stat.h> #include <sys/kernel.h> +#include <sys/pool.h> #include <ufs/ufs/dir.h> #include <uvm/uvm_extern.h> @@ -378,7 +379,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) return (0); } vrele(nd.ni_startdir); - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); vp = nd.ni_vp; bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; @@ -1328,7 +1329,7 @@ nfsrv_create(nfsd, slp, procp, mrq) vrele(nd.ni_startdir); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (!error) { - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); if (exclusive_flag) { exclusive_flag = 0; VATTR_NULL(&va); @@ -1345,7 +1346,7 @@ nfsrv_create(nfsd, slp, procp, mrq) if (va.va_type != VFIFO && (error = suser_ucred(cred))) { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); nfsm_reply(0); @@ -1356,7 +1357,7 @@ nfsrv_create(nfsd, slp, procp, mrq) &va); if (error) { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); nfsm_reply(0); return (0); } @@ -1365,12 +1366,12 @@ nfsrv_create(nfsd, slp, procp, mrq) nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = cred; if ((error = lookup(&nd)) != 0) { - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); nfsm_reply(0); return (0); } - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); if (nd.ni_cnd.cn_flags & ISSYMLINK) { vrele(nd.ni_dvp); vput(nd.ni_vp); @@ -1381,7 +1382,7 @@ nfsrv_create(nfsd, slp, procp, mrq) } } else { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); error = ENXIO; @@ -1389,7 +1390,7 @@ nfsrv_create(nfsd, slp, procp, mrq) vp = nd.ni_vp; } else { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); vp = nd.ni_vp; if (nd.ni_dvp == vp) vrele(nd.ni_dvp); @@ -1443,7 +1444,7 @@ nfsmout: vrele(dirp); if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); } VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) @@ -1506,7 +1507,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); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); error = NFSERR_BADTYPE; VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); @@ -1526,7 +1527,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); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); error = EEXIST; VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); @@ -1537,12 +1538,12 @@ nfsrv_mknod(nfsd, slp, procp, mrq) vrele(nd.ni_startdir); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (!error) - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); } else { if (va.va_type != VFIFO && (error = suser_ucred(cred))) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); goto out; @@ -1557,7 +1558,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); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); if (error) goto out; if (nd.ni_cnd.cn_flags & ISSYMLINK) { @@ -1591,7 +1592,7 @@ nfsmout: vrele(dirp); if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); - free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); } VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) @@ -1829,7 +1830,7 @@ out: error = 0; } vrele(tond.ni_startdir); - FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, tond.ni_cnd.cn_pnbuf); out1: if (fdirp) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); @@ -1840,7 +1841,7 @@ out1: vrele(tdirp); } vrele(fromnd.ni_startdir); - FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, fromnd.ni_cnd.cn_pnbuf); nfsm_reply(2 * NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); @@ -1855,11 +1856,11 @@ nfsmout: vrele(tdirp); if (tond.ni_cnd.cn_nameiop) { vrele(tond.ni_startdir); - FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, tond.ni_cnd.cn_pnbuf); } if (fromnd.ni_cnd.cn_nameiop) { vrele(fromnd.ni_startdir); - FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, fromnd.ni_cnd.cn_pnbuf); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); @@ -2035,7 +2036,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); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); @@ -2067,7 +2068,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) } } else vrele(nd.ni_startdir); - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); } out: if (pathcp) @@ -2088,7 +2089,7 @@ out: nfsmout: if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); } if (dirp) vrele(dirp); diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index 0ab1e612ba0..0cb86216853 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_subs.c,v 1.43 2003/06/02 23:28:19 millert Exp $ */ +/* $OpenBSD: nfs_subs.c,v 1.44 2004/05/14 04:00:34 tedu Exp $ */ /* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */ /* @@ -53,6 +53,7 @@ #include <sys/socketvar.h> #include <sys/stat.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/time.h> #include <uvm/uvm_extern.h> @@ -1355,7 +1356,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag) struct componentname *cnp = &ndp->ni_cnd; *retdirp = (struct vnode *)0; - MALLOC(cnp->cn_pnbuf, char *, len + 1, M_NAMEI, M_WAITOK); + cnp->cn_pnbuf = pool_get(&namei_pool, PR_WAITOK); /* * Copy the name from the mbuf list to ndp->ni_pnbuf * and set the various ndp fields appropriately. @@ -1442,7 +1443,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag) return (0); } out: - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); return (error); } diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 4a8ce4e0fa9..c54f7175049 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.59 2004/04/26 18:57:36 millert Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.60 2004/05/14 04:00:34 tedu Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -50,6 +50,7 @@ #include <sys/mount.h> #include <sys/buf.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/mbuf.h> #include <sys/conf.h> #include <sys/namei.h> @@ -1205,7 +1206,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) cache_enter(dvp, newvp, cnp); *vpp = newvp; } - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) VTONFS(dvp)->n_attrstamp = 0; @@ -1335,7 +1336,7 @@ again: cache_enter(dvp, newvp, cnp); *ap->a_vpp = newvp; } - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) VTONFS(dvp)->n_attrstamp = 0; @@ -1409,7 +1410,7 @@ nfs_remove(v) error = 0; } else if (!np->n_sillyrename) error = nfs_sillyrename(dvp, vp, cnp); - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); np->n_attrstamp = 0; vrele(dvp); vrele(vp); @@ -1615,7 +1616,7 @@ nfs_link(v) int v3; if (dvp->v_mount != vp->v_mount) { - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); if (vp == dvp) vrele(dvp); else @@ -1643,7 +1644,7 @@ nfs_link(v) nfsm_wcc_data(dvp, wccflag); } nfsm_reqdone; - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!attrflag) VTONFS(vp)->n_attrstamp = 0; @@ -1712,7 +1713,7 @@ nfs_symlink(v) nfsm_reqdone; if (newvp) vrele(newvp); - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) VTONFS(dvp)->n_attrstamp = 0; @@ -1802,7 +1803,7 @@ nfs_mkdir(v) vrele(newvp); } else *ap->a_vpp = newvp; - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vrele(dvp); return (error); } @@ -1833,7 +1834,7 @@ nfs_rmdir(v) if (dvp == vp) { vrele(dvp); vrele(dvp); - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); return (EINVAL); } nfsstats.rpccnt[NFSPROC_RMDIR]++; @@ -1845,7 +1846,7 @@ nfs_rmdir(v) if (v3) nfsm_wcc_data(dvp, wccflag); nfsm_reqdone; - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) VTONFS(dvp)->n_attrstamp = 0; diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 32fad7dd0e5..8e6b0390e07 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.h,v 1.70 2004/01/14 19:34:05 grange Exp $ */ +/* $OpenBSD: malloc.h,v 1.71 2004/05/14 04:00:33 tedu Exp $ */ /* $NetBSD: malloc.h,v 1.39 1998/07/12 19:52:01 augustss Exp $ */ /* @@ -70,7 +70,7 @@ #define M_IFADDR 9 /* interface address */ #define M_SOOPTS 10 /* socket options */ #define M_SYSCTL 11 /* sysctl buffers (persistent storage) */ -#define M_NAMEI 12 /* namei path name buffer */ +/* 12 - free */ /* 13 - free */ #define M_IOCTLOPS 14 /* ioctl data buffer */ /* 15-18 - free */ @@ -188,7 +188,7 @@ "ifaddr", /* 9 M_IFADDR */ \ "soopts", /* 10 M_SOOPTS */ \ "sysctl", /* 11 M_SYSCTL */ \ - "namei", /* 12 M_NAMEI */ \ + NULL, \ NULL, \ "ioctlops", /* 14 M_IOCTLOPS */ \ NULL, \ diff --git a/sys/sys/namei.h b/sys/sys/namei.h index cca303ba747..681c2c66d5f 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -1,4 +1,4 @@ -/* $OpenBSD: namei.h,v 1.12 2003/06/02 23:28:21 millert Exp $ */ +/* $OpenBSD: namei.h,v 1.13 2004/05/14 04:00:33 tedu Exp $ */ /* $NetBSD: namei.h,v 1.11 1996/02/09 18:25:20 christos Exp $ */ /* @@ -183,6 +183,8 @@ void nchinit(void); struct mount; void cache_purgevfs(struct mount *); +extern struct pool namei_pool; + #endif /* diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index 3643daa378d..db8f6fc7553 100644 --- a/sys/ufs/ext2fs/ext2fs_vnops.c +++ b/sys/ufs/ext2fs/ext2fs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vnops.c,v 1.33 2004/03/02 05:52:24 tedu Exp $ */ +/* $OpenBSD: ext2fs_vnops.c,v 1.34 2004/05/14 04:00:34 tedu Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */ /* @@ -537,7 +537,7 @@ ext2fs_link(v) ip->i_e2fs_nlink--; ip->i_flag |= IN_CHANGE; } - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); out1: if (dvp != vp) VOP_UNLOCK(vp, 0, p); @@ -1066,7 +1066,7 @@ bad: } else *ap->a_vpp = tvp; out: - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); return (error); } @@ -1258,7 +1258,7 @@ ext2fs_makeinode(mode, dvp, vpp, cnp) if ((error = ext2fs_inode_alloc(pdir, mode, cnp->cn_cred, &tvp)) != 0) { - free(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); return (error); } @@ -1283,7 +1283,7 @@ ext2fs_makeinode(mode, dvp, vpp, cnp) if (error != 0) goto bad; if ((cnp->cn_flags & SAVESTART) == 0) - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); *vpp = tvp; return (0); @@ -1293,7 +1293,7 @@ bad: * Write error occurred trying to update the inode * or the directory so must deallocate the inode. */ - free(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); ip->i_e2fs_nlink = 0; ip->i_flag |= IN_CHANGE; diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c index c16615ef9ad..a36910d9a6d 100644 --- a/sys/ufs/ufs/ufs_extattr.c +++ b/sys/ufs/ufs/ufs_extattr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_extattr.c,v 1.4 2003/08/15 20:32:21 tedu Exp $ */ +/* $OpenBSD: ufs_extattr.c,v 1.5 2004/05/14 04:00:34 tedu Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson * Copyright (c) 2002 Networks Associates Technology, Inc. @@ -48,6 +48,7 @@ #include <sys/kernel.h> #include <sys/namei.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/fcntl.h> #include <sys/proc.h> #include <sys/vnode.h> @@ -276,7 +277,7 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname, cnp.cn_flags |= LOCKPARENT; cnp.cn_proc = p; cnp.cn_cred = p->p_ucred; - MALLOC(cnp.cn_pnbuf, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); + cnp.cn_pnbuf = pool_get(&namei_pool, PR_WAITOK); cnp.cn_nameptr = cnp.cn_pnbuf; error = copystr(dirname, cnp.cn_pnbuf, MAXPATHLEN, @@ -285,7 +286,7 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname, if (lockparent == UE_GETDIR_LOCKPARENT_DONT) { VOP_UNLOCK(start_dvp, 0, p); } - FREE(cnp.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp.cn_pnbuf); printf("ufs_extattr_lookup: copystr failed\n"); return (error); } @@ -295,7 +296,7 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname, vargs.a_vpp = &target_vp; vargs.a_cnp = &cnp; error = ufs_lookup(&vargs); - FREE(cnp.cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp.cn_pnbuf); if (error) { /* diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index c350bdc1dd4..70b22d04c5f 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vnops.c,v 1.54 2003/12/28 17:20:16 tedu Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.55 2004/05/14 04:00:34 tedu Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -50,6 +50,7 @@ #include <sys/mount.h> #include <sys/vnode.h> #include <sys/malloc.h> +#include <sys/pool.h> #include <sys/dirent.h> #include <sys/lockf.h> #include <sys/event.h> @@ -725,7 +726,7 @@ ufs_link(v) if (DOINGSOFTDEP(vp)) softdep_change_linkcnt(ip); } - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); VN_KNOTE(vp, NOTE_LINK); VN_KNOTE(dvp, NOTE_WRITE); out1: @@ -791,7 +792,7 @@ ufs_whiteout(v) /* NOTREACHED */ } if (cnp->cn_flags & HASBUF) { - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); cnp->cn_flags &= ~HASBUF; } return (error); @@ -1281,7 +1282,7 @@ ufs_mkdir(v) if ((error = getinoquota(ip)) || (error = ufs_quota_alloc_inode(ip, cnp->cn_cred))) { - free(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); UFS_INODE_FREE(ip, ip->i_number, dmode); vput(tvp); vput(dvp); @@ -1387,7 +1388,7 @@ bad: vput(tvp); } out: - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); return (error); @@ -2094,7 +2095,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) mode |= IFREG; if ((error = UFS_INODE_ALLOC(pdir, mode, cnp->cn_cred, &tvp)) != 0) { - free(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); return (error); } @@ -2104,7 +2105,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) if ((error = getinoquota(ip)) || (error = ufs_quota_alloc_inode(ip, cnp->cn_cred))) { - free(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); UFS_INODE_FREE(ip, ip->i_number, mode); vput(tvp); vput(dvp); @@ -2137,7 +2138,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) goto bad; if ((cnp->cn_flags & SAVESTART) == 0) - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); *vpp = tvp; return (0); @@ -2147,7 +2148,7 @@ bad: * Write error occurred trying to update the inode * or the directory so must deallocate the inode. */ - free(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); ip->i_effnlink = 0; ip->i_ffs_nlink = 0; diff --git a/sys/xfs/xfs_vnodeops-bsd.c b/sys/xfs/xfs_vnodeops-bsd.c index edc9f4d6590..7aee4bb3e0d 100644 --- a/sys/xfs/xfs_vnodeops-bsd.c +++ b/sys/xfs/xfs_vnodeops-bsd.c @@ -51,6 +51,8 @@ #include <vm/vnode_pager.h> #endif +#include <sys/pool.h> + RCSID("$arla: xfs_vnodeops-bsd.c,v 1.123 2003/02/15 16:40:36 lha Exp $"); /* @@ -353,7 +355,7 @@ cleanup_cnp (struct componentname *cnp, int error) #elif defined(PNBUF_PUT) PNBUF_PUT(cnp->cn_pnbuf); #else - FREE (cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); #endif } } @@ -977,7 +979,7 @@ xfs_abortop (struct vop_abortop_args *ap) #elif defined(PNBUF_PUT) PNBUF_PUT(cnp->cn_pnbuf); #else - FREE(cnp->cn_pnbuf, M_NAMEI); + pool_put(&namei_pool, cnp->cn_pnbuf); #endif return 0; } |