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 the pssTable mutex into a kmutex/cv.



details:   https://anonhg.NetBSD.org/src/rev/f6831e6ae0f4
branches:  trunk
changeset: 764759:f6831e6ae0f4
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue May 03 08:18:43 2011 +0000

description:
convert the pssTable mutex into a kmutex/cv.

diffstat:

 sys/dev/raidframe/rf_psstatus.c    |  23 ++++++++++++++---------
 sys/dev/raidframe/rf_psstatus.h    |  24 ++++++++++++------------
 sys/dev/raidframe/rf_threadstuff.h |   6 +++---
 3 files changed, 29 insertions(+), 24 deletions(-)

diffs (153 lines):

diff -r d308d0c7d595 -r f6831e6ae0f4 sys/dev/raidframe/rf_psstatus.c
--- a/sys/dev/raidframe/rf_psstatus.c   Tue May 03 07:56:42 2011 +0000
+++ b/sys/dev/raidframe/rf_psstatus.c   Tue May 03 08:18:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_psstatus.c,v 1.33 2006/11/16 01:33:23 christos Exp $        */
+/*     $NetBSD: rf_psstatus.c,v 1.34 2011/05/03 08:18:43 mrg Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -37,7 +37,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.33 2006/11/16 01:33:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.34 2011/05/03 08:18:43 mrg Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -106,7 +106,8 @@
                  raidPtr->pssTableSize * sizeof(RF_PSStatusHeader_t),
                  (RF_PSStatusHeader_t *));
        for (i = 0; i < raidPtr->pssTableSize; i++) {
-               rf_mutex_init(&pssTable[i].mutex);
+               rf_init_mutex2(pssTable[i].mutex, IPL_VM);
+               rf_init_cond2(pssTable[i].cond, "rfpsslk");
        }
        return (pssTable);
 }
@@ -115,9 +116,9 @@
 rf_FreeParityStripeStatusTable(RF_Raid_t *raidPtr,
                               RF_PSStatusHeader_t *pssTable)
 {
-#if RF_DEBUG_PSS
        int     i;
 
+#if RF_DEBUG_PSS
        if (rf_pssDebug)
                RealPrintPSStatusTable(raidPtr, pssTable);
 
@@ -127,6 +128,10 @@
                }
        }
 #endif
+       for (i = 0; i < raidPtr->pssTableSize; i++) {
+               rf_destroy_mutex2(pssTable[i].mutex);
+               rf_destroy_cond2(pssTable[i].cond);
+       }
        RF_Free(pssTable, raidPtr->pssTableSize * sizeof(RF_PSStatusHeader_t));
 }
 
@@ -219,12 +224,12 @@
        RF_ReconParityStripeStatus_t *p, *pt;
        RF_CallbackDesc_t *cb, *cb1;
 
-       RF_LOCK_MUTEX(hdr->mutex);
+       rf_lock_mutex2(hdr->mutex);
        while(hdr->lock) {
-               ltsleep(&hdr->lock, PRIBIO, "rf_racrecon", 0, &hdr->mutex);
+               rf_wait_cond2(hdr->cond, hdr->mutex);
        }
        hdr->lock = 1;
-       RF_UNLOCK_MUTEX(hdr->mutex);
+       rf_unlock_mutex2(hdr->mutex);
        for (pt = NULL, p = hdr->chain; p; pt = p, p = p->next) {
                if ((p->parityStripeID == psid) && (p->which_ru == which_ru))
                        break;
@@ -243,9 +248,9 @@
                hdr->chain = p->next;
        p->next = NULL;
 
-       RF_LOCK_MUTEX(hdr->mutex);
+       rf_lock_mutex2(hdr->mutex);
        hdr->lock = 0;
-       RF_UNLOCK_MUTEX(hdr->mutex);
+       rf_unlock_mutex2(hdr->mutex);
 
        /* wakup anyone waiting on the parity stripe ID */
        cb = p->procWaitList;
diff -r d308d0c7d595 -r f6831e6ae0f4 sys/dev/raidframe/rf_psstatus.h
--- a/sys/dev/raidframe/rf_psstatus.h   Tue May 03 07:56:42 2011 +0000
+++ b/sys/dev/raidframe/rf_psstatus.h   Tue May 03 08:18:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_psstatus.h,v 1.13 2006/02/14 01:13:33 oster Exp $   */
+/*     $NetBSD: rf_psstatus.h,v 1.14 2011/05/03 08:18:43 mrg Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -56,21 +56,20 @@
 #define RF_HASH_PSID(_raid_,_psid_) ( (_psid_) % ((_raid_)->pssTableSize) )    /* simple hash function */
 #define RF_LOCK_PSS_MUTEX(_raidPtr, _psid)                                                      \
   do {                                                                                          \
-     RF_LOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);   \
+     rf_lock_mutex2((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);  \
      while((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock) {           \
-          ltsleep(&(_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock,     \
-                 PRIBIO, "rflockpss", 0,                                                       \
-                 &(_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);   \
+          rf_wait_cond2((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].cond,\
+                       (_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);\
      }                                                                                          \
      (_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock = 1;               \
-     RF_UNLOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex); \
+     rf_unlock_mutex2((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);\
   } while (0);
 
 #define RF_UNLOCK_PSS_MUTEX(_raidPtr, _psid)                                                    \
-  RF_LOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);      \
+  rf_lock_mutex2((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);     \
   (_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock = 0;                  \
-  wakeup(&(_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock);             \
-  RF_UNLOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);
+  rf_broadcast_cond2((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].cond);  \
+  rf_unlock_mutex2((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);
 
 struct RF_ReconParityStripeStatus_s {
        RF_StripeNum_t parityStripeID;  /* the parity stripe ID */
@@ -99,9 +98,10 @@
 };
 
 struct RF_PSStatusHeader_s {
-       RF_DECLARE_MUTEX(mutex) /* mutex for this hash chain */
-       int lock;               /* 1 if this hash chain is locked,
-                                  0 otherwise */
+       rf_declare_mutex2(mutex);       /* mutex for this hash chain */
+       rf_declare_cond2(cond);         /* and cv for it */
+       int lock;                       /* 1 if this hash chain is locked,
+                                          0 otherwise */
        RF_ReconParityStripeStatus_t *chain;    /* the hash chain */
 };
 /* masks for the "flags" field above */
diff -r d308d0c7d595 -r f6831e6ae0f4 sys/dev/raidframe/rf_threadstuff.h
--- a/sys/dev/raidframe/rf_threadstuff.h        Tue May 03 07:56:42 2011 +0000
+++ b/sys/dev/raidframe/rf_threadstuff.h        Tue May 03 08:18:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_threadstuff.h,v 1.29 2011/05/02 01:07:24 mrg Exp $  */
+/*     $NetBSD: rf_threadstuff.h,v 1.30 2011/05/03 08:18:43 mrg Exp $  */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -100,11 +100,11 @@
  */
 
 #define        RF_CREATE_THREAD(_handle_, _func_, _arg_, _name_) \
-       kthread_create(PRI_NONE, 0, NULL, (void (*)(void *))(_func_), \
+       kthread_create(PRI_SOFTBIO, 0, NULL, (void (*)(void *))(_func_), \
            (void *)(_arg_), &(_handle_), _name_)
 
 #define        RF_CREATE_ENGINE_THREAD(_handle_, _func_, _arg_, _fmt_, _fmt_arg_) \
-       kthread_create(PRI_NONE, 0, NULL, (void (*)(void *))(_func_), \
+       kthread_create(PRI_SOFTBIO, 0, NULL, (void (*)(void *))(_func_), \
            (void *)(_arg_), &(_handle_), _fmt_, _fmt_arg_)
 
 #endif                         /* !_RF__RF_THREADSTUFF_H_ */



Home | Main Index | Thread Index | Old Index