Module Name: src
Committed By: mrg
Date: Wed Apr 27 07:55:15 UTC 2011
Modified Files:
src/sys/dev/raidframe: rf_acctrace.h rf_driver.c rf_driver.h
rf_engine.c rf_netbsdkintf.c rf_paritymap.c rf_raid.h rf_states.c
rf_threadstuff.h
Log Message:
prepare to convert more raidframe old lock/sleep APIs to mutex/condvar:
- remove RF_DECLARE_EXTERN_MUTEX and RF_DECLARE_STATIC_MUTEX, the qualifier
can be provided at the use point with the normal define
- rename the *LGMGR_MUTEX() macros to *mutex2() names, and add some more
defines for use:
rf_declare_mutex2()
rf_declare_cond2()
rf_lock_mutex2()
rf_unlock_mutex2()
rf_init_mutex2()
rf_destroy_mutex2()
rf_init_cond2()
rf_destroy_cond2()
rf_wait_cond2()
rf_signal_cond2()
rf_broadcast_cond2()
- use the new names for the configureMutex(), which previous used some combo
of direct mutex* calls and macros
- convert the node_queue to use a mutex/cv combo
- in rf_ShutdownEngine() and DAGExecutionThread(), also signal the former from
the latter when it is done and about to exit
- convert iodone_lock to use the new macros
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/raidframe/rf_acctrace.h
cvs rdiff -u -r1.124 -r1.125 src/sys/dev/raidframe/rf_driver.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/raidframe/rf_driver.h
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/raidframe/rf_engine.c
cvs rdiff -u -r1.285 -r1.286 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/raidframe/rf_paritymap.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/raidframe/rf_raid.h
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/raidframe/rf_states.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/raidframe/rf_threadstuff.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/raidframe/rf_acctrace.h
diff -u src/sys/dev/raidframe/rf_acctrace.h:1.8 src/sys/dev/raidframe/rf_acctrace.h:1.9
--- src/sys/dev/raidframe/rf_acctrace.h:1.8 Sun Dec 11 12:23:37 2005
+++ src/sys/dev/raidframe/rf_acctrace.h Wed Apr 27 07:55:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_acctrace.h,v 1.8 2005/12/11 12:23:37 christos Exp $ */
+/* $NetBSD: rf_acctrace.h,v 1.9 2011/04/27 07:55:14 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -123,7 +123,7 @@
RF_Hist_t tot_hist[RF_HIST_NUM_BUCKETS];
} RF_AccTotals_t;
-RF_DECLARE_EXTERN_MUTEX(rf_tracing_mutex)
+extern RF_DECLARE_MUTEX(rf_tracing_mutex);
int rf_ConfigureAccessTrace(RF_ShutdownList_t ** listp);
Index: src/sys/dev/raidframe/rf_driver.c
diff -u src/sys/dev/raidframe/rf_driver.c:1.124 src/sys/dev/raidframe/rf_driver.c:1.125
--- src/sys/dev/raidframe/rf_driver.c:1.124 Sat Apr 23 22:22:46 2011
+++ src/sys/dev/raidframe/rf_driver.c Wed Apr 27 07:55:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.c,v 1.124 2011/04/23 22:22:46 mrg Exp $ */
+/* $NetBSD: rf_driver.c,v 1.125 2011/04/27 07:55:14 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.124 2011/04/23 22:22:46 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.125 2011/04/27 07:55:14 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_raid_diagnostic.h"
@@ -145,8 +145,8 @@
static int configureCount = 0; /* number of active configurations */
static int isconfigged = 0; /* is basic raidframe (non per-array)
* stuff configured */
-RF_DECLARE_LKMGR_STATIC_MUTEX(configureMutex) /* used to lock the configuration
- * stuff */
+static rf_declare_mutex2(configureMutex); /* used to lock the configuration
+ * stuff */
static RF_ShutdownList_t *globalShutdown; /* non array-specific
* stuff */
@@ -162,7 +162,7 @@
if (raidframe_booted)
return (EBUSY);
raidframe_booted = 1;
- mutex_init(&configureMutex, MUTEX_DEFAULT, IPL_NONE);
+ rf_init_mutex2(configureMutex, IPL_NONE);
configureCount = 0;
isconfigged = 0;
globalShutdown = NULL;
@@ -176,7 +176,7 @@
rf_UnconfigureArray(void)
{
- RF_LOCK_LKMGR_MUTEX(configureMutex);
+ rf_lock_mutex2(configureMutex);
if (--configureCount == 0) { /* if no active configurations, shut
* everything down */
isconfigged = 0;
@@ -191,7 +191,7 @@
rf_print_unfreed();
#endif
}
- RF_UNLOCK_LKMGR_MUTEX(configureMutex);
+ rf_unlock_mutex2(configureMutex);
}
/*
@@ -265,7 +265,7 @@
RF_ERRORMSG2("RAIDFRAME: failed %s with %d\n", RF_STRING(f), rc); \
rf_ShutdownList(&globalShutdown); \
configureCount--; \
- RF_UNLOCK_LKMGR_MUTEX(configureMutex); \
+ rf_unlock_mutex2(configureMutex); \
return(rc); \
} \
}
@@ -296,7 +296,7 @@
RF_RowCol_t col;
int rc;
- RF_LOCK_LKMGR_MUTEX(configureMutex);
+ rf_lock_mutex2(configureMutex);
configureCount++;
if (isconfigged == 0) {
rf_mutex_init(&rf_printf_mutex);
@@ -329,7 +329,7 @@
DO_INIT_CONFIGURE(rf_ConfigurePSStatus);
isconfigged = 1;
}
- RF_UNLOCK_LKMGR_MUTEX(configureMutex);
+ rf_unlock_mutex2(configureMutex);
DO_RAID_MUTEX(&raidPtr->mutex);
/* set up the cleanup list. Do this after ConfigureDebug so that
Index: src/sys/dev/raidframe/rf_driver.h
diff -u src/sys/dev/raidframe/rf_driver.h:1.17 src/sys/dev/raidframe/rf_driver.h:1.18
--- src/sys/dev/raidframe/rf_driver.h:1.17 Sun Mar 4 06:02:38 2007
+++ src/sys/dev/raidframe/rf_driver.h Wed Apr 27 07:55:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.h,v 1.17 2007/03/04 06:02:38 christos Exp $ */
+/* $NetBSD: rf_driver.h,v 1.18 2011/04/27 07:55:15 mrg Exp $ */
/*
* rf_driver.h
*/
@@ -41,7 +41,7 @@
#define RF_RETRY_THRESHOLD 5
#endif
-RF_DECLARE_EXTERN_MUTEX(rf_printf_mutex)
+extern RF_DECLARE_MUTEX(rf_printf_mutex);
int rf_BootRaidframe(void);
int rf_UnbootRaidframe(void);
int rf_Shutdown(RF_Raid_t *);
Index: src/sys/dev/raidframe/rf_engine.c
diff -u src/sys/dev/raidframe/rf_engine.c:1.43 src/sys/dev/raidframe/rf_engine.c:1.44
--- src/sys/dev/raidframe/rf_engine.c:1.43 Sat Apr 23 22:22:46 2011
+++ src/sys/dev/raidframe/rf_engine.c Wed Apr 27 07:55:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_engine.c,v 1.43 2011/04/23 22:22:46 mrg Exp $ */
+/* $NetBSD: rf_engine.c,v 1.44 2011/04/27 07:55:15 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.43 2011/04/23 22:22:46 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_engine.c,v 1.44 2011/04/27 07:55:15 mrg Exp $");
#include <sys/errno.h>
@@ -77,51 +77,52 @@
/* synchronization primitives for this file. DO_WAIT should be enclosed in a while loop. */
#define DO_LOCK(_r_) \
-do { \
- ks = splbio(); \
- RF_LOCK_MUTEX((_r_)->node_queue_mutex); \
-} while (0)
+ rf_lock_mutex2((_r_)->node_queue_mutex)
#define DO_UNLOCK(_r_) \
-do { \
- RF_UNLOCK_MUTEX((_r_)->node_queue_mutex); \
- splx(ks); \
-} while (0)
+ rf_unlock_mutex2((_r_)->node_queue_mutex)
#define DO_WAIT(_r_) \
- RF_WAIT_COND((_r_)->node_queue, (_r_)->node_queue_mutex)
+ rf_wait_cond2((_r_)->node_queue_cv, (_r_)->node_queue_mutex)
#define DO_SIGNAL(_r_) \
- RF_BROADCAST_COND((_r_)->node_queue) /* XXX RF_SIGNAL_COND? */
+ rf_broadcast_cond2((_r_)->node_queue_cv) /* XXX RF_SIGNAL_COND? */
static void
rf_ShutdownEngine(void *arg)
{
RF_Raid_t *raidPtr;
- int ks;
raidPtr = (RF_Raid_t *) arg;
/* Tell the rf_RaidIOThread to shutdown */
- mutex_enter(&raidPtr->iodone_lock);
+ rf_lock_mutex2(raidPtr->iodone_lock);
raidPtr->shutdown_raidio = 1;
- cv_signal(&raidPtr->iodone_cv);
+ rf_signal_cond2(raidPtr->iodone_cv);
/* ...and wait for it to tell us it has finished */
while (raidPtr->shutdown_raidio)
- cv_wait(&raidPtr->iodone_cv, &raidPtr->iodone_lock);
+ rf_wait_cond2(raidPtr->iodone_cv, raidPtr->iodone_lock);
- mutex_exit(&raidPtr->iodone_lock);
+ rf_unlock_mutex2(raidPtr->iodone_lock);
/* Now shut down the DAG execution engine. */
DO_LOCK(raidPtr);
raidPtr->shutdown_engine = 1;
DO_SIGNAL(raidPtr);
+
+ /* ...and wait for it to tell us it has finished */
+ while (raidPtr->shutdown_engine)
+ DO_WAIT(raidPtr);
+
DO_UNLOCK(raidPtr);
- mutex_destroy(&raidPtr->iodone_lock);
- cv_destroy(&raidPtr->iodone_cv);
+ rf_destroy_mutex2(raidPtr->node_queue_mutex);
+ rf_destroy_cond2(raidPtr->node_queue_cv);
+
+ rf_destroy_mutex2(raidPtr->iodone_lock);
+ rf_destroy_cond2(raidPtr->iodone_cv);
}
int
@@ -133,10 +134,11 @@
* Initialise iodone for the IO thread.
*/
TAILQ_INIT(&(raidPtr->iodone));
- mutex_init(&raidPtr->iodone_lock, MUTEX_DEFAULT, IPL_VM);
- cv_init(&raidPtr->iodone_cv, "raidiow");
+ rf_init_mutex2(raidPtr->iodone_lock, IPL_VM);
+ rf_init_cond2(raidPtr->iodone_cv, "raidiow");
- rf_mutex_init(&raidPtr->node_queue_mutex);
+ rf_init_mutex2(raidPtr->node_queue_mutex, IPL_VM);
+ rf_init_cond2(raidPtr->node_queue_cv, "rfwcond");
raidPtr->node_queue = NULL;
raidPtr->dags_in_flight = 0;
@@ -425,7 +427,7 @@
{
RF_DagNode_t *s, *a;
RF_Raid_t *raidPtr;
- int i, ks;
+ int i;
RF_DagNode_t *finishlist = NULL; /* a list of NIL nodes to be
* finished */
RF_DagNode_t *skiplist = NULL; /* list of nodes with failed truedata
@@ -750,8 +752,6 @@
{
RF_DagNode_t *nd, *local_nq, *term_nq, *fire_nq;
RF_Raid_t *raidPtr;
- int ks;
- int s;
raidPtr = (RF_Raid_t *) arg;
@@ -760,7 +760,6 @@
printf("raid%d: Engine thread is running\n", raidPtr->raidid);
}
#endif
- s = splbio();
DO_LOCK(raidPtr);
while (!raidPtr->shutdown_engine) {
@@ -830,9 +829,13 @@
DO_WAIT(raidPtr);
}
}
+
+ /* Let rf_ShutdownEngine know that we're done... */
+ raidPtr->shutdown_engine = 0;
+ DO_SIGNAL(raidPtr);
+
DO_UNLOCK(raidPtr);
- splx(s);
kthread_exit(0);
}
@@ -851,49 +854,46 @@
{
RF_Raid_t *raidPtr;
RF_DiskQueueData_t *req;
- int s;
raidPtr = (RF_Raid_t *) arg;
- s = splbio();
- mutex_enter(&raidPtr->iodone_lock);
+ rf_lock_mutex2(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)) {
- cv_wait(&raidPtr->iodone_cv, &raidPtr->iodone_lock);
+ rf_wait_cond2(raidPtr->iodone_cv, raidPtr->iodone_lock);
}
/* Check for deferred parity-map-related work. */
if (raidPtr->parity_map != NULL) {
- mutex_exit(&raidPtr->iodone_lock);
+ rf_unlock_mutex2(raidPtr->iodone_lock);
rf_paritymap_checkwork(raidPtr->parity_map);
- mutex_enter(&raidPtr->iodone_lock);
+ rf_lock_mutex2(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);
- mutex_exit(&raidPtr->iodone_lock);
+ rf_unlock_mutex2(raidPtr->iodone_lock);
rf_DiskIOComplete(req->queue, req, req->error);
(req->CompleteFunc) (req->argument, req->error);
- mutex_enter(&raidPtr->iodone_lock);
+ rf_lock_mutex2(raidPtr->iodone_lock);
}
/* process any pending outgoing IO */
- mutex_exit(&raidPtr->iodone_lock);
+ rf_unlock_mutex2(raidPtr->iodone_lock);
raidstart(raidPtr);
- mutex_enter(&raidPtr->iodone_lock);
+ rf_lock_mutex2(raidPtr->iodone_lock);
}
/* Let rf_ShutdownEngine know that we're done... */
raidPtr->shutdown_raidio = 0;
- cv_signal(&raidPtr->iodone_cv);
+ rf_signal_cond2(raidPtr->iodone_cv);
- mutex_exit(&raidPtr->iodone_lock);
- splx(s);
+ rf_unlock_mutex2(raidPtr->iodone_lock);
kthread_exit(0);
}
Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.285 src/sys/dev/raidframe/rf_netbsdkintf.c:1.286
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.285 Sat Apr 23 06:29:05 2011
+++ src/sys/dev/raidframe/rf_netbsdkintf.c Wed Apr 27 07:55:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.285 2011/04/23 06:29:05 mrg Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.286 2011/04/27 07:55:15 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.285 2011/04/23 06:29:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.286 2011/04/27 07:55:15 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -162,7 +162,7 @@
static RF_Raid_t **raidPtrs; /* global raid device descriptors */
#if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0)
-RF_DECLARE_STATIC_MUTEX(rf_sparet_wait_mutex)
+static RF_DECLARE_MUTEX(rf_sparet_wait_mutex)
static RF_SparetWait_t *rf_sparet_wait_queue; /* requests to install a
* spare table */
@@ -879,7 +879,7 @@
}
}
- mutex_enter(&raidPtr->iodone_lock);
+ rf_lock_mutex2(raidPtr->iodone_lock);
bp->b_resid = 0;
@@ -887,8 +887,8 @@
bufq_put(rs->buf_queue, bp);
/* scheduled the IO to happen at the next convenient time */
- cv_signal(&raidPtr->iodone_cv);
- mutex_exit(&raidPtr->iodone_lock);
+ rf_signal_cond2(raidPtr->iodone_cv);
+ rf_unlock_mutex2(raidPtr->iodone_lock);
return;
@@ -2166,7 +2166,7 @@
queue = (RF_DiskQueue_t *) req->queue;
- mutex_enter(&queue->raidPtr->iodone_lock);
+ rf_lock_mutex2(queue->raidPtr->iodone_lock);
#if RF_ACC_TRACE > 0
if (req->tracerec) {
@@ -2215,9 +2215,9 @@
TAILQ_INSERT_TAIL(&(queue->raidPtr->iodone), req, iodone_entries);
/* Let the raidio thread know there is work to be done. */
- cv_signal(&queue->raidPtr->iodone_cv);
+ rf_signal_cond2(queue->raidPtr->iodone_cv);
- mutex_exit(&queue->raidPtr->iodone_lock);
+ rf_unlock_mutex2(queue->raidPtr->iodone_lock);
}
Index: src/sys/dev/raidframe/rf_paritymap.c
diff -u src/sys/dev/raidframe/rf_paritymap.c:1.7 src/sys/dev/raidframe/rf_paritymap.c:1.8
--- src/sys/dev/raidframe/rf_paritymap.c:1.7 Sat Apr 23 06:29:05 2011
+++ src/sys/dev/raidframe/rf_paritymap.c Wed Apr 27 07:55:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_paritymap.c,v 1.7 2011/04/23 06:29:05 mrg Exp $ */
+/* $NetBSD: rf_paritymap.c,v 1.8 2011/04/27 07:55:15 mrg Exp $ */
/*-
* Copyright (c) 2009 Jed Davis.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.7 2011/04/23 06:29:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.8 2011/04/27 07:55:15 mrg Exp $");
#include <sys/param.h>
#include <sys/callout.h>
@@ -260,9 +260,9 @@
pm->flags |= TICKED;
mutex_exit(&pm->lk_flags);
- mutex_enter(&pm->raid->iodone_lock);
- cv_signal(&pm->raid->iodone_cv); /* XXX */
- mutex_exit(&pm->raid->iodone_lock);
+ rf_lock_mutex2(pm->raid->iodone_lock);
+ rf_signal_cond2(pm->raid->iodone_cv); /* XXX */
+ rf_unlock_mutex2(pm->raid->iodone_lock);
}
/*
@@ -585,10 +585,10 @@
if (raidPtr->parity_map == NULL)
return;
- mutex_enter(&raidPtr->iodone_lock);
+ rf_lock_mutex2(raidPtr->iodone_lock);
struct rf_paritymap *pm = raidPtr->parity_map;
raidPtr->parity_map = NULL;
- mutex_exit(&raidPtr->iodone_lock);
+ rf_unlock_mutex2(raidPtr->iodone_lock);
/* XXXjld is that enough locking? Or too much? */
rf_paritymap_destroy(pm, 0);
kmem_free(pm, sizeof(*pm));
Index: src/sys/dev/raidframe/rf_raid.h
diff -u src/sys/dev/raidframe/rf_raid.h:1.39 src/sys/dev/raidframe/rf_raid.h:1.40
--- src/sys/dev/raidframe/rf_raid.h:1.39 Sat Apr 23 06:29:05 2011
+++ src/sys/dev/raidframe/rf_raid.h Wed Apr 27 07:55:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_raid.h,v 1.39 2011/04/23 06:29:05 mrg Exp $ */
+/* $NetBSD: rf_raid.h,v 1.40 2011/04/27 07:55:15 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -162,8 +162,8 @@
callback functions. */
TAILQ_HEAD(iodone_q,RF_DiskQueueData_s) iodone;
/* and a lock/cv to protect it */
- kmutex_t iodone_lock;
- kcondvar_t iodone_cv;
+ rf_declare_mutex2(iodone_lock);
+ rf_declare_cond2(iodone_cv);
RF_VoidPointerListElem_t *iobuf; /* I/O buffer free list */
@@ -216,7 +216,8 @@
/*
* Engine thread control
*/
- RF_DECLARE_MUTEX(node_queue_mutex)
+ rf_declare_mutex2(node_queue_mutex);
+ rf_declare_cond2(node_queue_cv);
RF_DagNode_t *node_queue;
RF_Thread_t parity_rewrite_thread;
RF_Thread_t copyback_thread;
Index: src/sys/dev/raidframe/rf_states.c
diff -u src/sys/dev/raidframe/rf_states.c:1.45 src/sys/dev/raidframe/rf_states.c:1.46
--- src/sys/dev/raidframe/rf_states.c:1.45 Sat Apr 23 06:29:05 2011
+++ src/sys/dev/raidframe/rf_states.c Wed Apr 27 07:55:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_states.c,v 1.45 2011/04/23 06:29:05 mrg Exp $ */
+/* $NetBSD: rf_states.c,v 1.46 2011/04/27 07:55:15 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.45 2011/04/23 06:29:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.46 2011/04/27 07:55:15 mrg Exp $");
#include <sys/errno.h>
@@ -236,9 +236,9 @@
((RF_Raid_t *) desc->raidPtr)->openings++;
RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
- mutex_enter(&desc->raidPtr->iodone_lock);
- cv_signal(&desc->raidPtr->iodone_cv);
- mutex_exit(&desc->raidPtr->iodone_lock);
+ rf_lock_mutex2(desc->raidPtr->iodone_lock);
+ rf_signal_cond2(desc->raidPtr->iodone_cv);
+ rf_unlock_mutex2(desc->raidPtr->iodone_lock);
/*
* The parity_map hook has to go here, because the iodone
Index: src/sys/dev/raidframe/rf_threadstuff.h
diff -u src/sys/dev/raidframe/rf_threadstuff.h:1.24 src/sys/dev/raidframe/rf_threadstuff.h:1.25
--- src/sys/dev/raidframe/rf_threadstuff.h:1.24 Wed Dec 5 08:39:53 2007
+++ src/sys/dev/raidframe/rf_threadstuff.h Wed Apr 27 07:55:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_threadstuff.h,v 1.24 2007/12/05 08:39:53 ad Exp $ */
+/* $NetBSD: rf_threadstuff.h,v 1.25 2011/04/27 07:55:15 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -53,40 +53,47 @@
#include <dev/raidframe/raidframevar.h>
-#define decl_simple_lock_data(a,b) a struct simplelock b;
+/* Old school simple_lock */
typedef struct lwp *RF_Thread_t;
typedef void *RF_ThreadArg_t;
-#define RF_DECLARE_MUTEX(_m_) decl_simple_lock_data(,(_m_))
-#define RF_DECLARE_STATIC_MUTEX(_m_) decl_simple_lock_data(static,(_m_))
-#define RF_DECLARE_EXTERN_MUTEX(_m_) decl_simple_lock_data(extern,(_m_))
+#define RF_DECLARE_MUTEX(_m_) struct simplelock _m_;
#define RF_DECLARE_COND(_c_) int _c_;
#define RF_LOCK_MUTEX(_m_) simple_lock(&(_m_))
#define RF_UNLOCK_MUTEX(_m_) simple_unlock(&(_m_))
+#define RF_WAIT_COND(_c_,_m_) \
+ ltsleep(&(_c_), PRIBIO, "rfwcond", 0, &(_m_))
+#define RF_SIGNAL_COND(_c_) wakeup_one(&(_c_))
+#define RF_BROADCAST_COND(_c_) wakeup(&(_c_))
-/* non-spinlock */
-#define decl_lock_data(a,b) a kmutex_t b;
-
-#define RF_DECLARE_LKMGR_MUTEX(_m_) decl_lock_data(,(_m_))
-#define RF_DECLARE_LKMGR_STATIC_MUTEX(_m_) decl_lock_data(static,(_m_))
-#define RF_DECLARE_LKMGR_EXTERN_MUTEX(_m_) decl_lock_data(extern,(_m_))
-
-#define RF_LOCK_LKMGR_MUTEX(_m_) mutex_enter(&(_m_))
-#define RF_UNLOCK_LKMGR_MUTEX(_m_) mutex_exit(&(_m_))
+/* Modern mutex */
+/* Note that rf_declare_{mutex,cond}2() do _NOT_ append the ; */
+#define rf_declare_mutex2(_m_) kmutex_t _m_
+#define rf_declare_cond2(_c_) kcondvar_t _c_
+
+#define rf_lock_mutex2(_m_) mutex_enter(&(_m_))
+#define rf_unlock_mutex2(_m_) mutex_exit(&(_m_))
+
+#define rf_init_mutex2(_m_, _p_) mutex_init(&(_m_), MUTEX_DEFAULT, (_p_))
+#define rf_destroy_mutex2(_m_) mutex_destroy(&(_m_))
+
+#define rf_init_cond2(_c_, _w_) cv_init(&(_c_), (_w_))
+#define rf_destroy_cond2(_c_) cv_destroy(&(_c_))
+
+#define rf_wait_cond2(_c_,_m_) cv_wait(&(_c_), &(_m_))
+#define rf_signal_cond2(_c_) cv_signal(&(_c_))
+#define rf_broadcast_cond2(_c_) cv_broadcast(&(_c_))
/*
* In NetBSD, kernel threads are simply processes which share several
* substructures and never run in userspace.
*/
-#define RF_WAIT_COND(_c_,_m_) \
- ltsleep(&(_c_), PRIBIO, "rfwcond", 0, &(_m_))
-#define RF_SIGNAL_COND(_c_) wakeup_one(&(_c_))
-#define RF_BROADCAST_COND(_c_) wakeup(&(_c_))
+
#define RF_CREATE_THREAD(_handle_, _func_, _arg_, _name_) \
kthread_create(PRI_NONE, 0, NULL, (void (*)(void *))(_func_), \
(void *)(_arg_), &(_handle_), _name_)