Module Name:    src
Committed By:   mrg
Date:           Tue May  3 08:18:43 UTC 2011

Modified Files:
        src/sys/dev/raidframe: rf_psstatus.c rf_psstatus.h rf_threadstuff.h

Log Message:
convert the pssTable mutex into a kmutex/cv.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/raidframe/rf_psstatus.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/raidframe/rf_psstatus.h
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/raidframe/rf_threadstuff.h

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_psstatus.c
diff -u src/sys/dev/raidframe/rf_psstatus.c:1.33 src/sys/dev/raidframe/rf_psstatus.c:1.34
--- src/sys/dev/raidframe/rf_psstatus.c:1.33	Thu Nov 16 01:33:23 2006
+++ src/sys/dev/raidframe/rf_psstatus.c	Tue May  3 08:18:43 2011
@@ -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;

Index: src/sys/dev/raidframe/rf_psstatus.h
diff -u src/sys/dev/raidframe/rf_psstatus.h:1.13 src/sys/dev/raidframe/rf_psstatus.h:1.14
--- src/sys/dev/raidframe/rf_psstatus.h:1.13	Tue Feb 14 01:13:33 2006
+++ src/sys/dev/raidframe/rf_psstatus.h	Tue May  3 08:18:43 2011
@@ -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 */

Index: src/sys/dev/raidframe/rf_threadstuff.h
diff -u src/sys/dev/raidframe/rf_threadstuff.h:1.29 src/sys/dev/raidframe/rf_threadstuff.h:1.30
--- src/sys/dev/raidframe/rf_threadstuff.h:1.29	Mon May  2 01:07:24 2011
+++ src/sys/dev/raidframe/rf_threadstuff.h	Tue May  3 08:18:43 2011
@@ -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_ */

Reply via email to