Module Name: src Committed By: mrg Date: Thu May 5 07:12:58 UTC 2011
Modified Files: src/sys/dev/raidframe: rf_driver.c rf_raid.h rf_states.c Log Message: convert access_suspend_mutex to a kmutex/cv. To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/sys/dev/raidframe/rf_driver.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/raidframe/rf_raid.h cvs rdiff -u -r1.46 -r1.47 src/sys/dev/raidframe/rf_states.c 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_driver.c diff -u src/sys/dev/raidframe/rf_driver.c:1.126 src/sys/dev/raidframe/rf_driver.c:1.127 --- src/sys/dev/raidframe/rf_driver.c:1.126 Sat Apr 30 01:44:36 2011 +++ src/sys/dev/raidframe/rf_driver.c Thu May 5 07:12:58 2011 @@ -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 @@ 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_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 @@ } \ } -#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_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 @@ 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 @@ 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 @@ 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 @@ 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; Index: src/sys/dev/raidframe/rf_raid.h diff -u src/sys/dev/raidframe/rf_raid.h:1.41 src/sys/dev/raidframe/rf_raid.h:1.42 --- src/sys/dev/raidframe/rf_raid.h:1.41 Sat Apr 30 01:44:36 2011 +++ src/sys/dev/raidframe/rf_raid.h Thu May 5 07:12:58 2011 @@ -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 @@ /* * 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; Index: src/sys/dev/raidframe/rf_states.c diff -u src/sys/dev/raidframe/rf_states.c:1.46 src/sys/dev/raidframe/rf_states.c:1.47 --- src/sys/dev/raidframe/rf_states.c:1.46 Wed Apr 27 07:55:15 2011 +++ src/sys/dev/raidframe/rf_states.c Thu May 5 07:12:58 2011 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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);