summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2005-04-19 15:32:13 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2005-04-19 15:32:13 +0000
commit0ba1fd24a3fda2072d4c6858529542eef59b2498 (patch)
tree3cb8502b42bd19f6acf968d3ad54b497d234c39d /sys/dev
parent59ad80f2e0263fe5914ec08e4adf85fe3f5bf3f1 (diff)
use pool for struct vndbug; tested by many and pedro@ ok
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/vnd.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index bfd31b32470..5a911946d52 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.54 2005/04/12 13:25:37 joris Exp $ */
+/* $OpenBSD: vnd.c,v 1.55 2005/04/19 15:32:12 mickey Exp $ */
/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
@@ -67,6 +67,7 @@
#include <sys/errno.h>
#include <sys/buf.h>
#include <sys/malloc.h>
+#include <sys/pool.h>
#include <sys/ioctl.h>
#include <sys/disklabel.h>
#include <sys/device.h>
@@ -111,10 +112,13 @@ struct vndbuf {
struct buf *vb_obp;
};
-#define getvndbuf() \
- ((struct vndbuf *)malloc(sizeof(struct vndbuf), M_DEVBUF, M_WAITOK))
-#define putvndbuf(vbp) \
- free((caddr_t)(vbp), M_DEVBUF)
+/*
+ * struct vndbuf allocator
+ */
+struct pool vndbufpl;
+
+#define getvndbuf() pool_get(&vndbufpl, PR_WAITOK)
+#define putvndbuf(vbp) pool_put(&vndbufpl, vbp);
struct vnd_softc {
struct device sc_dev;
@@ -205,6 +209,10 @@ vndattach(num)
bzero(mem, size);
vnd_softc = (struct vnd_softc *)mem;
numvnd = num;
+
+ pool_init(&vndbufpl, sizeof(struct vndbuf), 0, 0, 0, "vndbufpl", NULL);
+ pool_setlowat(&vndbufpl, 16);
+ pool_sethiwat(&vndbufpl, 1024);
}
int