Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/raidframe convert the iodone_lock to a mutex, and us...
details: https://anonhg.NetBSD.org/src/rev/c015702e7e70
branches: trunk
changeset: 764441:c015702e7e70
user: mrg <mrg%NetBSD.org@localhost>
date: Sat Apr 23 06:29:05 2011 +0000
description:
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:
sys/dev/raidframe/rf_driver.c | 10 +++++++---
sys/dev/raidframe/rf_engine.c | 34 ++++++++++++++++------------------
sys/dev/raidframe/rf_netbsdkintf.c | 34 ++++++++++++++--------------------
sys/dev/raidframe/rf_paritymap.c | 13 ++++++++-----
sys/dev/raidframe/rf_raid.h | 7 ++++---
sys/dev/raidframe/rf_states.c | 8 +++++---
6 files changed, 54 insertions(+), 52 deletions(-)
diffs (truncated from 323 to 300 lines):
diff -r 0fc66f194c51 -r c015702e7e70 sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c Fri Apr 22 14:18:34 2011 +0000
+++ b/sys/dev/raidframe/rf_driver.c Sat Apr 23 06:29:05 2011 +0000
@@ -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 @@
"rfreshutdown",0);
}
+ mutex_destroy(&raidPtr->iodone_lock);
+ cv_destroy(&raidPtr->iodone_cv);
+
raidPtr->valid = 0;
if (raidPtr->parity_map != NULL)
@@ -351,7 +354,8 @@
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 -r 0fc66f194c51 -r c015702e7e70 sys/dev/raidframe/rf_engine.c
--- a/sys/dev/raidframe/rf_engine.c Fri Apr 22 14:18:34 2011 +0000
+++ b/sys/dev/raidframe/rf_engine.c Sat Apr 23 06:29:05 2011 +0000
@@ -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 @@
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 @@
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 -r 0fc66f194c51 -r c015702e7e70 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c Fri Apr 22 14:18:34 2011 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c Sat Apr 23 06:29:05 2011 +0000
@@ -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 @@
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 @@
goto done;
}
}
- s = splbio();
+
+ mutex_enter(&raidPtr->iodone_lock);
bp->b_resid = 0;
@@ -888,9 +887,9 @@
bufq_put(rs->buf_queue, bp);
/* scheduled the IO to happen at the next convenient time */
- wakeup(&(raidPtrs[raidID]->iodone));
-
- splx(s);
+ cv_signal(&raidPtr->iodone_cv);
+ mutex_exit(&raidPtr->iodone_lock);
+
return;
done:
@@ -2160,14 +2159,15 @@
{
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 @@
}
/* 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));
-
- simple_unlock(&queue->raidPtr->iodone_lock);
-
- splx(s);
+ cv_signal(&queue->raidPtr->iodone_cv);
+
+ mutex_exit(&queue->raidPtr->iodone_lock);
}
-
/*
* initialize a buf structure for doing an I/O in the kernel.
*/
diff -r 0fc66f194c51 -r c015702e7e70 sys/dev/raidframe/rf_paritymap.c
--- a/sys/dev/raidframe/rf_paritymap.c Fri Apr 22 14:18:34 2011 +0000
+++ b/sys/dev/raidframe/rf_paritymap.c Sat Apr 23 06:29:05 2011 +0000
@@ -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 @@
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 @@
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 -r 0fc66f194c51 -r c015702e7e70 sys/dev/raidframe/rf_raid.h
--- a/sys/dev/raidframe/rf_raid.h Fri Apr 22 14:18:34 2011 +0000
+++ b/sys/dev/raidframe/rf_raid.h Sat Apr 23 06:29:05 2011 +0000
@@ -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 @@
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 -r 0fc66f194c51 -r c015702e7e70 sys/dev/raidframe/rf_states.c
--- a/sys/dev/raidframe/rf_states.c Fri Apr 22 14:18:34 2011 +0000
+++ b/sys/dev/raidframe/rf_states.c Sat Apr 23 06:29:05 2011 +0000
@@ -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 $ */
Home |
Main Index |
Thread Index |
Old Index