- convert rf_printf_mutex to a kmutex

- convert rf_rad_lock and the per-raid "cv" to per-raid kmutex/and real cv
- use rf_mutex_init() in places, and move it with the similar definitions
This commit is contained in:
mrg 2011-04-30 01:44:36 +00:00
parent fc6d41fbf1
commit 2b448af86b
7 changed files with 38 additions and 35 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_driver.c,v 1.125 2011/04/27 07:55:14 mrg Exp $ */ /* $NetBSD: rf_driver.c,v 1.126 2011/04/30 01:44:36 mrg Exp $ */
/*- /*-
* Copyright (c) 1999 The NetBSD Foundation, Inc. * Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -66,7 +66,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.125 2011/04/27 07:55:14 mrg Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.126 2011/04/30 01:44:36 mrg Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_raid_diagnostic.h" #include "opt_raid_diagnostic.h"
@ -118,7 +118,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.125 2011/04/27 07:55:14 mrg Exp $");
#endif #endif
/* rad == RF_RaidAccessDesc_t */ /* rad == RF_RaidAccessDesc_t */
RF_DECLARE_MUTEX(rf_rad_lock)
#define RF_MAX_FREE_RAD 128 #define RF_MAX_FREE_RAD 128
#define RF_MIN_FREE_RAD 32 #define RF_MIN_FREE_RAD 32
@ -134,7 +133,7 @@ static void rf_UnconfigureArray(void);
static void rf_ShutdownRDFreeList(void *); static void rf_ShutdownRDFreeList(void *);
static int rf_ConfigureRDFreeList(RF_ShutdownList_t **); static int rf_ConfigureRDFreeList(RF_ShutdownList_t **);
RF_DECLARE_MUTEX(rf_printf_mutex) /* debug only: avoids interleaved rf_declare_mutex2(rf_printf_mutex); /* debug only: avoids interleaved
* printfs by different stripes */ * printfs by different stripes */
#define SIGNAL_QUIESCENT_COND(_raid_) wakeup(&((_raid_)->accesses_suspended)) #define SIGNAL_QUIESCENT_COND(_raid_) wakeup(&((_raid_)->accesses_suspended))
@ -213,16 +212,16 @@ rf_Shutdown(RF_Raid_t *raidPtr)
* cuts down on the amount of serialization we've got going * cuts down on the amount of serialization we've got going
* on. * on.
*/ */
RF_LOCK_MUTEX(rf_rad_lock); rf_lock_mutex2(raidPtr->rad_lock);
if (raidPtr->waitShutdown) { if (raidPtr->waitShutdown) {
RF_UNLOCK_MUTEX(rf_rad_lock); rf_unlock_mutex2(raidPtr->rad_lock);
return (EBUSY); return (EBUSY);
} }
raidPtr->waitShutdown = 1; raidPtr->waitShutdown = 1;
while (raidPtr->nAccOutstanding) { while (raidPtr->nAccOutstanding) {
RF_WAIT_COND(raidPtr->outstandingCond, rf_rad_lock); rf_wait_cond2(raidPtr->outstandingCond, raidPtr->rad_lock);
} }
RF_UNLOCK_MUTEX(rf_rad_lock); rf_unlock_mutex2(raidPtr->rad_lock);
/* Wait for any parity re-writes to stop... */ /* Wait for any parity re-writes to stop... */
while (raidPtr->parity_rewrite_in_progress) { while (raidPtr->parity_rewrite_in_progress) {
@ -253,6 +252,9 @@ rf_Shutdown(RF_Raid_t *raidPtr)
rf_ShutdownList(&raidPtr->shutdownList); rf_ShutdownList(&raidPtr->shutdownList);
rf_destroy_cond2(raidPtr->outstandingCond);
rf_destroy_mutex2(raidPtr->rad_lock);
rf_UnconfigureArray(); rf_UnconfigureArray();
return (0); return (0);
@ -299,7 +301,7 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
rf_lock_mutex2(configureMutex); rf_lock_mutex2(configureMutex);
configureCount++; configureCount++;
if (isconfigged == 0) { if (isconfigged == 0) {
rf_mutex_init(&rf_printf_mutex); rf_init_mutex2(rf_printf_mutex, IPL_VM);
/* initialize globals */ /* initialize globals */
@ -353,7 +355,8 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine); DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine);
DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks); DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks);
raidPtr->outstandingCond = 0; rf_init_cond2(raidPtr->outstandingCond, "rfocond");
rf_init_mutex2(raidPtr->rad_lock, IPL_VM);
raidPtr->nAccOutstanding = 0; raidPtr->nAccOutstanding = 0;
raidPtr->waitShutdown = 0; raidPtr->waitShutdown = 0;
@ -544,7 +547,6 @@ rf_ConfigureRDFreeList(RF_ShutdownList_t **listp)
rf_pool_init(&rf_pools.rad, sizeof(RF_RaidAccessDesc_t), rf_pool_init(&rf_pools.rad, sizeof(RF_RaidAccessDesc_t),
"rf_rad_pl", RF_MIN_FREE_RAD, RF_MAX_FREE_RAD); "rf_rad_pl", RF_MIN_FREE_RAD, RF_MAX_FREE_RAD);
rf_ShutdownCreate(listp, rf_ShutdownRDFreeList, NULL); rf_ShutdownCreate(listp, rf_ShutdownRDFreeList, NULL);
simple_lock_init(&rf_rad_lock);
return (0); return (0);
} }
@ -558,20 +560,20 @@ rf_AllocRaidAccDesc(RF_Raid_t *raidPtr, RF_IoType_t type,
desc = pool_get(&rf_pools.rad, PR_WAITOK); desc = pool_get(&rf_pools.rad, PR_WAITOK);
RF_LOCK_MUTEX(rf_rad_lock); rf_lock_mutex2(raidPtr->rad_lock);
if (raidPtr->waitShutdown) { if (raidPtr->waitShutdown) {
/* /*
* Actually, we're shutting the array down. Free the desc * Actually, we're shutting the array down. Free the desc
* and return NULL. * and return NULL.
*/ */
RF_UNLOCK_MUTEX(rf_rad_lock); rf_unlock_mutex2(raidPtr->rad_lock);
pool_put(&rf_pools.rad, desc); pool_put(&rf_pools.rad, desc);
return (NULL); return (NULL);
} }
raidPtr->nAccOutstanding++; raidPtr->nAccOutstanding++;
RF_UNLOCK_MUTEX(rf_rad_lock); rf_unlock_mutex2(raidPtr->rad_lock);
desc->raidPtr = (void *) raidPtr; desc->raidPtr = (void *) raidPtr;
desc->type = type; desc->type = type;
@ -628,12 +630,12 @@ rf_FreeRaidAccDesc(RF_RaidAccessDesc_t *desc)
} }
pool_put(&rf_pools.rad, desc); pool_put(&rf_pools.rad, desc);
RF_LOCK_MUTEX(rf_rad_lock); rf_lock_mutex2(raidPtr->rad_lock);
raidPtr->nAccOutstanding--; raidPtr->nAccOutstanding--;
if (raidPtr->waitShutdown) { if (raidPtr->waitShutdown) {
RF_SIGNAL_COND(raidPtr->outstandingCond); rf_signal_cond2(raidPtr->outstandingCond);
} }
RF_UNLOCK_MUTEX(rf_rad_lock); rf_unlock_mutex2(raidPtr->rad_lock);
} }
/********************************************************************* /*********************************************************************
* Main routine for performing an access. * Main routine for performing an access.

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_driver.h,v 1.18 2011/04/27 07:55:15 mrg Exp $ */ /* $NetBSD: rf_driver.h,v 1.19 2011/04/30 01:44:36 mrg Exp $ */
/* /*
* rf_driver.h * rf_driver.h
*/ */
@ -41,7 +41,7 @@
#define RF_RETRY_THRESHOLD 5 #define RF_RETRY_THRESHOLD 5
#endif #endif
extern RF_DECLARE_MUTEX(rf_printf_mutex); extern rf_declare_mutex2(rf_printf_mutex);
int rf_BootRaidframe(void); int rf_BootRaidframe(void);
int rf_UnbootRaidframe(void); int rf_UnbootRaidframe(void);
int rf_Shutdown(RF_Raid_t *); int rf_Shutdown(RF_Raid_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_mcpair.c,v 1.22 2009/03/15 17:17:23 cegger Exp $ */ /* $NetBSD: rf_mcpair.c,v 1.23 2011/04/30 01:44:36 mrg Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.22 2009/03/15 17:17:23 cegger Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.23 2011/04/30 01:44:36 mrg Exp $");
#include <dev/raidframe/raidframevar.h> #include <dev/raidframe/raidframevar.h>
@ -75,7 +75,7 @@ rf_AllocMCPair(void)
RF_MCPair_t *t; RF_MCPair_t *t;
t = pool_get(&rf_pools.mcpair, PR_WAITOK); t = pool_get(&rf_pools.mcpair, PR_WAITOK);
simple_lock_init(&t->mutex); rf_mutex_init(&t->mutex);
t->cond = 0; t->cond = 0;
t->flag = 0; t->flag = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_raid.h,v 1.40 2011/04/27 07:55:15 mrg Exp $ */ /* $NetBSD: rf_raid.h,v 1.41 2011/04/30 01:44:36 mrg Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -249,7 +249,8 @@ struct RF_Raid_s {
* for a per-array piece of data, but otherwise, it'd be an extra * for a per-array piece of data, but otherwise, it'd be an extra
* per-array lock, and that'd only be less efficient...) * per-array lock, and that'd only be less efficient...)
*/ */
RF_DECLARE_COND(outstandingCond) rf_declare_mutex2(rad_lock);
rf_declare_cond2(outstandingCond);
int waitShutdown; int waitShutdown;
int nAccOutstanding; int nAccOutstanding;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_reconutil.c,v 1.28 2007/03/04 06:02:39 christos Exp $ */ /* $NetBSD: rf_reconutil.c,v 1.29 2011/04/30 01:44:36 mrg Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -31,7 +31,7 @@
********************************************/ ********************************************/
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.28 2007/03/04 06:02:39 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.29 2011/04/30 01:44:36 mrg Exp $");
#include <dev/raidframe/raidframevar.h> #include <dev/raidframe/raidframevar.h>
@ -125,13 +125,13 @@ rf_MakeReconControl(RF_RaidReconDesc_t *reconDesc,
} }
/* initialize the event queue */ /* initialize the event queue */
simple_lock_init(&reconCtrlPtr->eq_mutex); rf_mutex_init(&reconCtrlPtr->eq_mutex);
reconCtrlPtr->eventQueue = NULL; reconCtrlPtr->eventQueue = NULL;
reconCtrlPtr->eq_count = 0; reconCtrlPtr->eq_count = 0;
/* make the floating recon buffers and append them to the free list */ /* make the floating recon buffers and append them to the free list */
simple_lock_init(&reconCtrlPtr->rb_mutex); rf_mutex_init(&reconCtrlPtr->rb_mutex);
reconCtrlPtr->fullBufferList = NULL; reconCtrlPtr->fullBufferList = NULL;
reconCtrlPtr->floatingRbufs = NULL; reconCtrlPtr->floatingRbufs = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_stripelocks.c,v 1.30 2009/03/15 17:17:23 cegger Exp $ */ /* $NetBSD: rf_stripelocks.c,v 1.31 2011/04/30 01:44:36 mrg Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -57,7 +57,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.30 2009/03/15 17:17:23 cegger Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.31 2011/04/30 01:44:36 mrg Exp $");
#include <dev/raidframe/raidframevar.h> #include <dev/raidframe/raidframevar.h>
@ -658,7 +658,7 @@ PrintLockedStripes(RF_LockTableEntry_t *lockTable)
RF_StripeLockDesc_t *p; RF_StripeLockDesc_t *p;
RF_LockReqDesc_t *q; RF_LockReqDesc_t *q;
RF_LOCK_MUTEX(rf_printf_mutex); rf_lock_mutex2(rf_printf_mutex);
printf("Locked stripes:\n"); printf("Locked stripes:\n");
for (i = 0; i < rf_lockTableSize; i++) for (i = 0; i < rf_lockTableSize; i++)
if (lockTable[i].descList) { if (lockTable[i].descList) {
@ -714,6 +714,6 @@ PrintLockedStripes(RF_LockTableEntry_t *lockTable)
printf("(none)\n"); printf("(none)\n");
else else
printf("\n"); printf("\n");
RF_UNLOCK_MUTEX(rf_printf_mutex); rf_unlock_mutex2(rf_printf_mutex);
} }
#endif #endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_threadstuff.h,v 1.25 2011/04/27 07:55:15 mrg Exp $ */ /* $NetBSD: rf_threadstuff.h,v 1.26 2011/04/30 01:44:36 mrg Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -70,6 +70,8 @@ typedef void *RF_ThreadArg_t;
#define RF_SIGNAL_COND(_c_) wakeup_one(&(_c_)) #define RF_SIGNAL_COND(_c_) wakeup_one(&(_c_))
#define RF_BROADCAST_COND(_c_) wakeup(&(_c_)) #define RF_BROADCAST_COND(_c_) wakeup(&(_c_))
#define rf_mutex_init(m) simple_lock_init(m)
/* Modern mutex */ /* Modern mutex */
/* Note that rf_declare_{mutex,cond}2() do _NOT_ append the ; */ /* Note that rf_declare_{mutex,cond}2() do _NOT_ append the ; */
@ -102,6 +104,4 @@ typedef void *RF_ThreadArg_t;
kthread_create(PRI_NONE, 0, NULL, (void (*)(void *))(_func_), \ kthread_create(PRI_NONE, 0, NULL, (void (*)(void *))(_func_), \
(void *)(_arg_), &(_handle_), _fmt_, _fmt_arg_) (void *)(_arg_), &(_handle_), _fmt_, _fmt_arg_)
#define rf_mutex_init(m) simple_lock_init(m)
#endif /* !_RF__RF_THREADSTUFF_H_ */ #endif /* !_RF__RF_THREADSTUFF_H_ */