summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>2011-04-23 06:29:05 +0000
committermrg <mrg@NetBSD.org>2011-04-23 06:29:05 +0000
commit6db600c1994ac9607e1b77e09b45d928c9fca43e (patch)
tree95fcb1a26fc82719dd75e0de92eeb9d0cdd835f2 /sys/dev/raidframe
parent8b0f03ae3fed5899cb62921d595f490f10100e77 (diff)
convert the iodone_lock to a mutex, and use a condvar for signalling.
this only handles the smallest use of old simple_lock/tsleep/wakeup APIs inside raidframe, and it points out that cv(9)'s have only one wait channel per cv, whereas each tsleep() caller can specify a different wait channel. this change removes the difference between normal raidio and waiting for IO during shutdown. i've tested this one 3 systems, ran atf, and had mlelstv and rmind review the change.
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_driver.c10
-rw-r--r--sys/dev/raidframe/rf_engine.c34
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c28
-rw-r--r--sys/dev/raidframe/rf_paritymap.c13
-rw-r--r--sys/dev/raidframe/rf_raid.h7
-rw-r--r--sys/dev/raidframe/rf_states.c8
6 files changed, 51 insertions, 49 deletions
diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c
index e049f178932..1a5b2c242d8 100644
--- a/sys/dev/raidframe/rf_driver.c
+++ b/sys/dev/raidframe/rf_driver.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.c,v 1.122 2009/11/17 18:54:26 jld Exp $ */
+/* $NetBSD: rf_driver.c,v 1.123 2011/04/23 06:29:05 mrg Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -66,7 +66,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.122 2009/11/17 18:54:26 jld Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.123 2011/04/23 06:29:05 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_raid_diagnostic.h"
@@ -240,6 +240,9 @@ rf_Shutdown(RF_Raid_t *raidPtr)
"rfreshutdown",0);
}
+ mutex_destroy(&raidPtr->iodone_lock);
+ cv_destroy(&raidPtr->iodone_cv);
+
raidPtr->valid = 0;
if (raidPtr->parity_map != NULL)
@@ -351,7 +354,8 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
raidPtr->reconControl = NULL;
TAILQ_INIT(&(raidPtr->iodone));
- simple_lock_init(&(raidPtr->iodone_lock));
+ mutex_init(&raidPtr->iodone_lock, MUTEX_DEFAULT, IPL_VM);
+ cv_init(&raidPtr->iodone_cv, "raidiow");
DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine);
DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks);
diff --git a/sys/dev/raidframe/rf_engine.c b/sys/dev/raidframe/rf_engine.c
index 3aabff6d246..d6f2f0dfb80 100644
--- a/sys/dev/raidframe/rf_engine.c
+++ b/sys/dev/raidframe/rf_engine.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_engine.c,v 1.41 2010/09/13 08:43:06 drochner Exp $ */
+/* $NetBSD: rf_engine.c,v 1.42 2011/04/23 06:29:05 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -55,7 +55,7 @@
****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_engine.c,v 1.41 2010/09/13 08:43:06 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_engine.c,v 1.42 2011/04/23 06:29:05 mrg Exp $");
#include <sys/errno.h>
@@ -103,17 +103,16 @@ rf_ShutdownEngine(void *arg)
raidPtr = (RF_Raid_t *) arg;
/* Tell the rf_RaidIOThread to shutdown */
- simple_lock(&(raidPtr->iodone_lock));
+ mutex_enter(&raidPtr->iodone_lock);
raidPtr->shutdown_raidio = 1;
- wakeup(&(raidPtr->iodone));
+ cv_signal(&raidPtr->iodone_cv);
/* ...and wait for it to tell us it has finished */
while (raidPtr->shutdown_raidio)
- ltsleep(&(raidPtr->shutdown_raidio), PRIBIO, "raidshutdown", 0,
- &(raidPtr->iodone_lock));
+ cv_wait(&raidPtr->iodone_cv, &raidPtr->iodone_lock);
- simple_unlock(&(raidPtr->iodone_lock));
+ mutex_exit(&raidPtr->iodone_lock);
/* Now shut down the DAG execution engine. */
DO_LOCK(raidPtr);
@@ -848,44 +847,43 @@ rf_RaidIOThread(RF_ThreadArg_t arg)
raidPtr = (RF_Raid_t *) arg;
s = splbio();
- simple_lock(&(raidPtr->iodone_lock));
+ mutex_enter(&raidPtr->iodone_lock);
while (!raidPtr->shutdown_raidio) {
/* if there is nothing to do, then snooze. */
if (TAILQ_EMPTY(&(raidPtr->iodone)) &&
rf_buf_queue_check(raidPtr->raidid)) {
- ltsleep(&(raidPtr->iodone), PRIBIO, "raidiow", 0,
- &(raidPtr->iodone_lock));
+ cv_wait(&raidPtr->iodone_cv, &raidPtr->iodone_lock);
}
/* Check for deferred parity-map-related work. */
if (raidPtr->parity_map != NULL) {
- simple_unlock(&(raidPtr->iodone_lock));
+ mutex_exit(&raidPtr->iodone_lock);
rf_paritymap_checkwork(raidPtr->parity_map);
- simple_lock(&(raidPtr->iodone_lock));
+ mutex_enter(&raidPtr->iodone_lock);
}
/* See what I/Os, if any, have arrived */
while ((req = TAILQ_FIRST(&(raidPtr->iodone))) != NULL) {
TAILQ_REMOVE(&(raidPtr->iodone), req, iodone_entries);
- simple_unlock(&(raidPtr->iodone_lock));
+ mutex_exit(&raidPtr->iodone_lock);
rf_DiskIOComplete(req->queue, req, req->error);
(req->CompleteFunc) (req->argument, req->error);
- simple_lock(&(raidPtr->iodone_lock));
+ mutex_enter(&raidPtr->iodone_lock);
}
/* process any pending outgoing IO */
- simple_unlock(&(raidPtr->iodone_lock));
+ mutex_exit(&raidPtr->iodone_lock);
raidstart(raidPtr);
- simple_lock(&(raidPtr->iodone_lock));
+ mutex_enter(&raidPtr->iodone_lock);
}
/* Let rf_ShutdownEngine know that we're done... */
raidPtr->shutdown_raidio = 0;
- wakeup(&(raidPtr->shutdown_raidio));
+ cv_signal(&raidPtr->iodone_cv);
- simple_unlock(&(raidPtr->iodone_lock));
+ mutex_exit(&raidPtr->iodone_lock);
splx(s);
kthread_exit(0);
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index 2fed5dafc9f..ce01e97f539 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.284 2011/03/18 23:53:26 mrg Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.285 2011/04/23 06:29:05 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.284 2011/03/18 23:53:26 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.285 2011/04/23 06:29:05 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -829,8 +829,6 @@ raidclose(dev_t dev, int flags, int fmt, struct lwp *l)
void
raidstrategy(struct buf *bp)
{
- int s;
-
unsigned int raidID = raidunit(bp->b_dev);
RF_Raid_t *raidPtr;
struct raid_softc *rs = &raid_softc[raidID];
@@ -880,7 +878,8 @@ raidstrategy(struct buf *bp)
goto done;
}
}
- s = splbio();
+
+ mutex_enter(&raidPtr->iodone_lock);
bp->b_resid = 0;
@@ -888,9 +887,9 @@ raidstrategy(struct buf *bp)
bufq_put(rs->buf_queue, bp);
/* scheduled the IO to happen at the next convenient time */
- wakeup(&(raidPtrs[raidID]->iodone));
+ cv_signal(&raidPtr->iodone_cv);
+ mutex_exit(&raidPtr->iodone_lock);
- splx(s);
return;
done:
@@ -2160,14 +2159,15 @@ KernelWakeupFunc(struct buf *bp)
{
RF_DiskQueueData_t *req = NULL;
RF_DiskQueue_t *queue;
- int s;
- s = splbio();
db1_printf(("recovering the request queue:\n"));
+
req = bp->b_private;
queue = (RF_DiskQueue_t *) req->queue;
+ mutex_enter(&queue->raidPtr->iodone_lock);
+
#if RF_ACC_TRACE > 0
if (req->tracerec) {
RF_ETIMER_STOP(req->tracerec->timer);
@@ -2209,24 +2209,18 @@ KernelWakeupFunc(struct buf *bp)
}
/* Fill in the error value */
-
req->error = bp->b_error;
- simple_lock(&queue->raidPtr->iodone_lock);
-
/* Drop this one on the "finished" queue... */
TAILQ_INSERT_TAIL(&(queue->raidPtr->iodone), req, iodone_entries);
/* Let the raidio thread know there is work to be done. */
- wakeup(&(queue->raidPtr->iodone));
+ cv_signal(&queue->raidPtr->iodone_cv);
- simple_unlock(&queue->raidPtr->iodone_lock);
-
- splx(s);
+ mutex_exit(&queue->raidPtr->iodone_lock);
}
-
/*
* initialize a buf structure for doing an I/O in the kernel.
*/
diff --git a/sys/dev/raidframe/rf_paritymap.c b/sys/dev/raidframe/rf_paritymap.c
index 5d00002b944..b306bad312c 100644
--- a/sys/dev/raidframe/rf_paritymap.c
+++ b/sys/dev/raidframe/rf_paritymap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_paritymap.c,v 1.6 2011/03/01 22:51:14 riz Exp $ */
+/* $NetBSD: rf_paritymap.c,v 1.7 2011/04/23 06:29:05 mrg Exp $ */
/*-
* Copyright (c) 2009 Jed Davis.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.6 2011/03/01 22:51:14 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.7 2011/04/23 06:29:05 mrg Exp $");
#include <sys/param.h>
#include <sys/callout.h>
@@ -259,7 +259,10 @@ rf_paritymap_tick(void *arg)
mutex_enter(&pm->lk_flags);
pm->flags |= TICKED;
mutex_exit(&pm->lk_flags);
- wakeup(&(pm->raid->iodone)); /* XXX */
+
+ mutex_enter(&pm->raid->iodone_lock);
+ cv_signal(&pm->raid->iodone_cv); /* XXX */
+ mutex_exit(&pm->raid->iodone_lock);
}
/*
@@ -582,10 +585,10 @@ rf_paritymap_detach(RF_Raid_t *raidPtr)
if (raidPtr->parity_map == NULL)
return;
- simple_lock(&(raidPtr->iodone_lock));
+ mutex_enter(&raidPtr->iodone_lock);
struct rf_paritymap *pm = raidPtr->parity_map;
raidPtr->parity_map = NULL;
- simple_unlock(&(raidPtr->iodone_lock));
+ mutex_exit(&raidPtr->iodone_lock);
/* XXXjld is that enough locking? Or too much? */
rf_paritymap_destroy(pm, 0);
kmem_free(pm, sizeof(*pm));
diff --git a/sys/dev/raidframe/rf_raid.h b/sys/dev/raidframe/rf_raid.h
index ffc022a2e9f..fb3c04d1782 100644
--- a/sys/dev/raidframe/rf_raid.h
+++ b/sys/dev/raidframe/rf_raid.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_raid.h,v 1.38 2009/11/17 18:54:26 jld Exp $ */
+/* $NetBSD: rf_raid.h,v 1.39 2011/04/23 06:29:05 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -161,8 +161,9 @@ struct RF_Raid_s {
a kernel thread deal with calling rf_DiskIOComplete and any
callback functions. */
TAILQ_HEAD(iodone_q,RF_DiskQueueData_s) iodone;
- /* and a lock to protect it */
- struct simplelock iodone_lock;
+ /* and a lock/cv to protect it */
+ kmutex_t iodone_lock;
+ kcondvar_t iodone_cv;
RF_VoidPointerListElem_t *iobuf; /* I/O buffer free list */
diff --git a/sys/dev/raidframe/rf_states.c b/sys/dev/raidframe/rf_states.c
index 3fd31195a7d..ce00183bc24 100644
--- a/sys/dev/raidframe/rf_states.c
+++ b/sys/dev/raidframe/rf_states.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_states.c,v 1.44 2009/11/17 18:54:26 jld Exp $ */
+/* $NetBSD: rf_states.c,v 1.45 2011/04/23 06:29:05 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.44 2009/11/17 18:54:26 jld Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.45 2011/04/23 06:29:05 mrg Exp $");
#include <sys/errno.h>
@@ -236,7 +236,9 @@ rf_State_LastState(RF_RaidAccessDesc_t *desc)
((RF_Raid_t *) desc->raidPtr)->openings++;
RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
- wakeup(&(desc->raidPtr->iodone));
+ mutex_enter(&desc->raidPtr->iodone_lock);
+ cv_signal(&desc->raidPtr->iodone_cv);
+ mutex_exit(&desc->raidPtr->iodone_lock);
/*
* The parity_map hook has to go here, because the iodone