summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-05-14 04:00:35 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-05-14 04:00:35 +0000
commitfca2cf71cc88b832f5e93f0288867997cb0d35d4 (patch)
treeb3b384460ab9208645ad0e2923d26d70668c0916 /sys/kern
parente517eaa484ed1d99ebecdc738e49a7d3d93aec3c (diff)
use pool for namei pathbuf. testing ok millert@ tdeval@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/exec_script.c7
-rw-r--r--sys/kern/kern_exec.c13
-rw-r--r--sys/kern/vfs_default.c5
-rw-r--r--sys/kern/vfs_init.c8
-rw-r--r--sys/kern/vfs_lookup.c21
-rw-r--r--sys/kern/vfs_syscalls.c11
6 files changed, 38 insertions, 27 deletions
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);