Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/raidframe convert access_suspend_mutex to a kmutex/cv.



details:   https://anonhg.NetBSD.org/src/rev/0049a3504d3f
branches:  trunk
changeset: 764801:0049a3504d3f
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu May 05 07:12:58 2011 +0000

description:
convert access_suspend_mutex to a kmutex/cv.

diffstat:

 sys/dev/raidframe/rf_driver.c |  31 ++++++++++++++++---------------
 sys/dev/raidframe/rf_raid.h   |   5 +++--
 sys/dev/raidframe/rf_states.c |  20 ++++++++++----------
 3 files changed, 29 insertions(+), 27 deletions(-)

diffs (205 lines):

diff -r e1105b2d7bb1 -r 0049a3504d3f sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c     Thu May 05 06:04:09 2011 +0000
+++ b/sys/dev/raidframe/rf_driver.c     Thu May 05 07:12:58 2011 +0000
@@ -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;
diff -r e1105b2d7bb1 -r 0049a3504d3f sys/dev/raidframe/rf_raid.h
--- a/sys/dev/raidframe/rf_raid.h       Thu May 05 06:04:09 2011 +0000
+++ b/sys/dev/raidframe/rf_raid.h       Thu May 05 07:12:58 2011 +0000
@@ -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;
diff -r e1105b2d7bb1 -r 0049a3504d3f sys/dev/raidframe/rf_states.c
--- a/sys/dev/raidframe/rf_states.c     Thu May 05 06:04:09 2011 +0000
+++ b/sys/dev/raidframe/rf_states.c     Thu May 05 07:12:58 2011 +0000
@@ -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);



Home | Main Index | Thread Index | Old Index