convert access_suspend_mutex to a kmutex/cv.

This commit is contained in:
mrg 2011-05-05 07:12:58 +00:00
parent ec1c557b57
commit 710e439b0e
3 changed files with 29 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_driver.c,v 1.126 2011/04/30 01:44:36 mrg Exp $ */
/* $NetBSD: rf_driver.c,v 1.127 2011/05/05 07:12:58 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.126 2011/04/30 01:44:36 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.127 2011/05/05 07:12:58 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_raid_diagnostic.h"
@ -136,10 +136,11 @@ static int rf_ConfigureRDFreeList(RF_ShutdownList_t **);
rf_declare_mutex2(rf_printf_mutex); /* debug only: avoids interleaved
* printfs by different stripes */
#define SIGNAL_QUIESCENT_COND(_raid_) wakeup(&((_raid_)->accesses_suspended))
#define SIGNAL_QUIESCENT_COND(_raid_) \
rf_broadcast_cond2((_raid_)->access_suspend_cv)
#define WAIT_FOR_QUIESCENCE(_raid_) \
ltsleep(&((_raid_)->accesses_suspended), PRIBIO, \
"raidframe quiesce", 0, &((_raid_)->access_suspend_mutex))
rf_wait_cond2((_raid_)->access_suspend_cv, \
(_raid_)->access_suspend_mutex)
static int configureCount = 0; /* number of active configurations */
static int isconfigged = 0; /* is basic raidframe (non per-array)
@ -252,6 +253,9 @@ rf_Shutdown(RF_Raid_t *raidPtr)
rf_ShutdownList(&raidPtr->shutdownList);
rf_destroy_mutex2(raidPtr->access_suspend_mutex);
rf_destroy_cond2(raidPtr->access_suspend_cv);
rf_destroy_cond2(raidPtr->outstandingCond);
rf_destroy_mutex2(raidPtr->rad_lock);
@ -288,10 +292,6 @@ rf_Shutdown(RF_Raid_t *raidPtr)
} \
}
#define DO_RAID_MUTEX(_m_) { \
rf_mutex_init((_m_)); \
}
int
rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
{
@ -333,7 +333,7 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
}
rf_unlock_mutex2(configureMutex);
DO_RAID_MUTEX(&raidPtr->mutex);
rf_mutex_init(&raidPtr->mutex);
/* set up the cleanup list. Do this after ConfigureDebug so that
* value of memDebug will be set */
@ -361,7 +361,8 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
raidPtr->nAccOutstanding = 0;
raidPtr->waitShutdown = 0;
DO_RAID_MUTEX(&raidPtr->access_suspend_mutex);
rf_init_mutex2(raidPtr->access_suspend_mutex, IPL_VM);
rf_init_cond2(raidPtr->access_suspend_cv, "rfquiesce");
raidPtr->waitForReconCond = 0;
@ -788,7 +789,7 @@ rf_SuspendNewRequestsAndWait(RF_Raid_t *raidPtr)
if (rf_quiesceDebug)
printf("raid%d: Suspending new reqs\n", raidPtr->raidid);
#endif
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_lock_mutex2(raidPtr->access_suspend_mutex);
raidPtr->accesses_suspended++;
raidPtr->waiting_for_quiescence = (raidPtr->accs_in_flight == 0) ? 0 : 1;
@ -807,7 +808,7 @@ rf_SuspendNewRequestsAndWait(RF_Raid_t *raidPtr)
printf("raid%d: Quiescence reached..\n", raidPtr->raidid);
#endif
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_unlock_mutex2(raidPtr->access_suspend_mutex);
return (raidPtr->waiting_for_quiescence);
}
/* wake up everyone waiting for quiescence to be released */
@ -821,14 +822,14 @@ rf_ResumeNewRequests(RF_Raid_t *raidPtr)
printf("raid%d: Resuming new requests\n", raidPtr->raidid);
#endif
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_lock_mutex2(raidPtr->access_suspend_mutex);
raidPtr->accesses_suspended--;
if (raidPtr->accesses_suspended == 0)
cb = raidPtr->quiesce_wait_list;
else
cb = NULL;
raidPtr->quiesce_wait_list = NULL;
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_unlock_mutex2(raidPtr->access_suspend_mutex);
while (cb) {
t = cb;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_raid.h,v 1.41 2011/04/30 01:44:36 mrg Exp $ */
/* $NetBSD: rf_raid.h,v 1.42 2011/05/05 07:12:58 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -195,7 +195,8 @@ struct RF_Raid_s {
/*
* Array-quiescence stuff
*/
RF_DECLARE_MUTEX(access_suspend_mutex)
rf_declare_mutex2(access_suspend_mutex);
rf_declare_cond2(access_suspend_cv);
RF_IoCount_t accesses_suspended;
RF_IoCount_t accs_in_flight;
int access_suspend_release;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_states.c,v 1.46 2011/04/27 07:55:15 mrg Exp $ */
/* $NetBSD: rf_states.c,v 1.47 2011/05/05 07:12:58 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.46 2011/04/27 07:55:15 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.47 2011/05/05 07:12:58 mrg Exp $");
#include <sys/errno.h>
@ -267,9 +267,9 @@ rf_State_IncrAccessCount(RF_RaidAccessDesc_t *desc)
raidPtr = desc->raidPtr;
/* Bummer. We have to do this to be 100% safe w.r.t. the increment
* below */
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_lock_mutex2(raidPtr->access_suspend_mutex);
raidPtr->accs_in_flight++; /* used to detect quiescence */
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_unlock_mutex2(raidPtr->access_suspend_mutex);
desc->state++;
return RF_FALSE;
@ -282,12 +282,12 @@ rf_State_DecrAccessCount(RF_RaidAccessDesc_t *desc)
raidPtr = desc->raidPtr;
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_lock_mutex2(raidPtr->access_suspend_mutex);
raidPtr->accs_in_flight--;
if (raidPtr->accesses_suspended && raidPtr->accs_in_flight == 0) {
rf_SignalQuiescenceLock(raidPtr);
}
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_unlock_mutex2(raidPtr->access_suspend_mutex);
desc->state++;
return RF_FALSE;
@ -316,12 +316,12 @@ rf_State_Quiesce(RF_RaidAccessDesc_t *desc)
used_cb = 0;
cb = NULL;
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_lock_mutex2(raidPtr->access_suspend_mutex);
/* Do an initial check to see if we might need a callback structure */
if (raidPtr->accesses_suspended) {
need_cb = 1;
}
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_unlock_mutex2(raidPtr->access_suspend_mutex);
if (need_cb) {
/* create a callback if we might need it...
@ -329,7 +329,7 @@ rf_State_Quiesce(RF_RaidAccessDesc_t *desc)
cb = rf_AllocCallbackDesc();
}
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_lock_mutex2(raidPtr->access_suspend_mutex);
if (raidPtr->accesses_suspended) {
cb->callbackFunc = (void (*) (RF_CBParam_t)) rf_ContinueRaidAccess;
cb->callbackArg.p = (void *) desc;
@ -338,7 +338,7 @@ rf_State_Quiesce(RF_RaidAccessDesc_t *desc)
suspended = RF_TRUE;
used_cb = 1;
}
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
rf_unlock_mutex2(raidPtr->access_suspend_mutex);
if ((need_cb == 1) && (used_cb == 0)) {
rf_FreeCallbackDesc(cb);