diff options
| author | mrg <mrg@NetBSD.org> | 2011-04-27 07:55:14 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2011-04-27 07:55:14 +0000 |
| commit | 2a7f34a2c758a508310cfb4c0e9d5c5b1fc4c398 (patch) | |
| tree | 23b3434931603002e7896fc3aecaebd0206500c7 /sys/dev/raidframe | |
| parent | af44b9a0f869d1cb5083eb2c41e73bc19fb55ec7 (diff) | |
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
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_acctrace.h | 4 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_driver.c | 20 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_driver.h | 4 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_engine.c | 80 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_netbsdkintf.c | 18 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_paritymap.c | 14 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_raid.h | 9 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_states.c | 10 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_threadstuff.h | 39 |
9 files changed, 103 insertions, 95 deletions
diff --git a/sys/dev/raidframe/rf_acctrace.h b/sys/dev/raidframe/rf_acctrace.h index 1e82317b6f3..29eaa09e9c5 100644 --- a/sys/dev/raidframe/rf_acctrace.h +++ b/sys/dev/raidframe/rf_acctrace.h @@ -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 @@ typedef struct RF_AccTotals_s { 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); diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c index 1df483c35af..952a4e17d30 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.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 @@ RF_DECLARE_MUTEX(rf_printf_mutex) /* debug only: avoids interleaved 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 @@ rf_BootRaidframe(void) 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 @@ static void 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_UnconfigureArray(void) rf_print_unfreed(); #endif } - RF_UNLOCK_LKMGR_MUTEX(configureMutex); + rf_unlock_mutex2(configureMutex); } /* @@ -265,7 +265,7 @@ rf_Shutdown(RF_Raid_t *raidPtr) 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_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac) 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 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac) 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 diff --git a/sys/dev/raidframe/rf_driver.h b/sys/dev/raidframe/rf_driver.h index d3aed547809..dbd58e24221 100644 --- a/sys/dev/raidframe/rf_driver.h +++ b/sys/dev/raidframe/rf_driver.h @@ -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 *); diff --git a/sys/dev/raidframe/rf_engine.c b/sys/dev/raidframe/rf_engine.c index 1df8d3c4112..16384aac274 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.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 @@ static void rf_RaidIOThread(RF_ThreadArg_t arg); /* 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 @@ rf_ConfigureEngine(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr, * 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 @@ PropagateResults(RF_DagNode_t *node, int context) { 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 @@ DAGExecutionThread(RF_ThreadArg_t arg) { 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 @@ DAGExecutionThread(RF_ThreadArg_t arg) printf("raid%d: Engine thread is running\n", raidPtr->raidid); } #endif - s = splbio(); DO_LOCK(raidPtr); while (!raidPtr->shutdown_engine) { @@ -830,9 +829,13 @@ DAGExecutionThread(RF_ThreadArg_t arg) 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_RaidIOThread(RF_ThreadArg_t arg) { 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); } diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index ce01e97f539..f8e42e6d77d 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.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 @@ int rf_kdebug_level = 0; 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 @@ raidstrategy(struct buf *bp) } } - mutex_enter(&raidPtr->iodone_lock); + rf_lock_mutex2(raidPtr->iodone_lock); bp->b_resid = 0; @@ -887,8 +887,8 @@ raidstrategy(struct buf *bp) 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 @@ KernelWakeupFunc(struct buf *bp) 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 @@ KernelWakeupFunc(struct buf *bp) 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); } diff --git a/sys/dev/raidframe/rf_paritymap.c b/sys/dev/raidframe/rf_paritymap.c index b306bad312c..dc7173d22e3 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.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 @@ rf_paritymap_tick(void *arg) 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 @@ rf_paritymap_detach(RF_Raid_t *raidPtr) 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)); diff --git a/sys/dev/raidframe/rf_raid.h b/sys/dev/raidframe/rf_raid.h index fb3c04d1782..ae76fa9662c 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.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 @@ struct RF_Raid_s { 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 @@ struct RF_Raid_s { /* * 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; diff --git a/sys/dev/raidframe/rf_states.c b/sys/dev/raidframe/rf_states.c index ce00183bc24..ab00c5529b2 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.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_State_LastState(RF_RaidAccessDesc_t *desc) ((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 diff --git a/sys/dev/raidframe/rf_threadstuff.h b/sys/dev/raidframe/rf_threadstuff.h index 4b416df4447..9ed8501eeb8 100644 --- a/sys/dev/raidframe/rf_threadstuff.h +++ b/sys/dev/raidframe/rf_threadstuff.h @@ -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_)) + + +/* 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_ -/* non-spinlock */ -#define decl_lock_data(a,b) a kmutex_t b; +#define rf_lock_mutex2(_m_) mutex_enter(&(_m_)) +#define rf_unlock_mutex2(_m_) mutex_exit(&(_m_)) -#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_init_mutex2(_m_, _p_) mutex_init(&(_m_), MUTEX_DEFAULT, (_p_)) +#define rf_destroy_mutex2(_m_) mutex_destroy(&(_m_)) -#define RF_LOCK_LKMGR_MUTEX(_m_) mutex_enter(&(_m_)) -#define RF_UNLOCK_LKMGR_MUTEX(_m_) mutex_exit(&(_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_) |
