summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2008-06-25 17:43:10 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2008-06-25 17:43:10 +0000
commitef2949192076d12d99e69d6ef6daed70cd930adb (patch)
tree7018ae29e0bb74211201bc5089ca05525bc4639c
parentb1e9de2094a255b79a0e729875b220313709937c (diff)
use pools for the uio and iovec allocations in sr_crypto_getcryptop()
instead of malloc; OK hshoexer@ and macro@
-rw-r--r--sys/dev/softraid.c22
-rw-r--r--sys/dev/softraid_crypto.c16
-rw-r--r--sys/dev/softraidvar.h6
3 files changed, 34 insertions, 10 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index eec9eaaffdb..a60ee5ca196 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.115 2008/06/14 18:40:50 hshoexer Exp $ */
+/* $OpenBSD: softraid.c,v 1.116 2008/06/25 17:43:09 thib Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -25,6 +25,7 @@
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/malloc.h>
+#include <sys/pool.h>
#include <sys/kernel.h>
#include <sys/disk.h>
#include <sys/rwlock.h>
@@ -63,6 +64,8 @@ uint32_t sr_debug = 0
;
#endif
+void sr_init(void);
+
int sr_match(struct device *, void *, void *);
void sr_attach(struct device *, struct device *, void *);
int sr_detach(struct device *, int);
@@ -128,6 +131,9 @@ void sr_print_metadata(struct sr_metadata *);
#define sr_print_metadata(m)
#endif
+struct pool sr_uiopl;
+struct pool sr_iovpl;
+
struct scsi_adapter sr_switch = {
sr_scsi_cmd, sr_minphys, NULL, NULL, sr_scsi_ioctl
};
@@ -136,9 +142,23 @@ struct scsi_device sr_dev = {
NULL, NULL, NULL, NULL
};
+void
+sr_init(void)
+{
+ pool_init(&sr_uiopl, sizeof(struct uio), 0, 0, 0, "sr_uiopl", NULL);
+ pool_init(&sr_iovpl, sizeof(struct iovec), 0, 0, 0, "sr_iovpl", NULL);
+}
+
int
sr_match(struct device *parent, void *match, void *aux)
{
+ static int called = 0;
+
+ if (!called) {
+ sr_init();
+ called = 1;
+ }
+
return (1);
}
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index 94d166e046e..5d955d561f7 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.27 2008/06/14 18:40:50 hshoexer Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.28 2008/06/25 17:43:09 thib Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -45,6 +45,7 @@
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/malloc.h>
+#include <sys/pool.h>
#include <sys/kernel.h>
#include <sys/disk.h>
#include <sys/rwlock.h>
@@ -107,9 +108,8 @@ sr_crypto_getcryptop(struct sr_workunit *wu, int encrypt)
DNPRINTF(SR_D_DIS, "%s: sr_crypto_getcryptop wu: %p encrypt: %d\n",
DEVNAME(sd->sd_sc), wu, encrypt);
- /* XXX use pool */
- uio = malloc(sizeof(*uio), M_DEVBUF, M_NOWAIT | M_ZERO);
- uio->uio_iov = malloc(sizeof(*uio->uio_iov), M_DEVBUF, M_NOWAIT);
+ uio = pool_get(&sr_uiopl, PR_WAITOK|PR_ZERO);
+ uio->uio_iov = pool_get(&sr_iovpl, PR_WAITOK);
uio->uio_iovcnt = 1;
uio->uio_iov->iov_len = xs->datalen;
if (xs->flags & SCSI_DATA_OUT) {
@@ -172,8 +172,8 @@ unwind:
crypto_freereq(crp);
if (wu->swu_xs->flags & SCSI_DATA_OUT)
free(uio->uio_iov->iov_base, M_DEVBUF);
- free(uio->uio_iov, M_DEVBUF);
- free(uio, M_DEVBUF);
+ pool_put(&sr_iovpl, uio->uio_iov);
+ pool_put(&sr_uiopl, uio);
return (NULL);
}
@@ -188,8 +188,8 @@ sr_crypto_putcryptop(struct cryptop *crp)
if (wu->swu_xs->flags & SCSI_DATA_OUT)
free(uio->uio_iov->iov_base, M_DEVBUF);
- free(uio->uio_iov, M_DEVBUF);
- free(uio, M_DEVBUF);
+ pool_put(&sr_iovpl, uio->uio_iov);
+ pool_put(&sr_uiopl, uio);
crypto_freereq(crp);
return (wu);
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index f44eeb0cb26..0b40b5ce047 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.59 2008/06/14 03:01:00 djm Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.60 2008/06/25 17:43:09 thib Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -429,6 +429,10 @@ struct sr_softc {
struct sr_discipline *sc_dis[SR_MAXSCSIBUS]; /* scsibus is u_int8_t */
};
+struct pool;
+extern struct pool sr_uiopl;
+extern struct pool sr_iovpl;
+
/* work units & ccbs */
int sr_alloc_ccb(struct sr_discipline *);
void sr_free_ccb(struct sr_discipline *);