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 rf_printf_mutex to a kmutex
details: https://anonhg.NetBSD.org/src/rev/d39f1ecb90f6
branches: trunk
changeset: 764669:d39f1ecb90f6
user: mrg <mrg%NetBSD.org@localhost>
date: Sat Apr 30 01:44:36 2011 +0000
description:
- convert rf_printf_mutex to a kmutex
- convert rf_rad_lock and the per-raid "cv" to per-raid kmutex/and real cv
- use rf_mutex_init() in places, and move it with the similar definitions
diffstat:
sys/dev/raidframe/rf_driver.c | 36 +++++++++++++++++++-----------------
sys/dev/raidframe/rf_driver.h | 4 ++--
sys/dev/raidframe/rf_mcpair.c | 6 +++---
sys/dev/raidframe/rf_raid.h | 5 +++--
sys/dev/raidframe/rf_reconutil.c | 8 ++++----
sys/dev/raidframe/rf_stripelocks.c | 8 ++++----
sys/dev/raidframe/rf_threadstuff.h | 6 +++---
7 files changed, 38 insertions(+), 35 deletions(-)
diffs (291 lines):
diff -r 0e3d6ef75d58 -r d39f1ecb90f6 sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c Sat Apr 30 01:10:07 2011 +0000
+++ b/sys/dev/raidframe/rf_driver.c Sat Apr 30 01:44:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.c,v 1.125 2011/04/27 07:55:14 mrg Exp $ */
+/* $NetBSD: rf_driver.c,v 1.126 2011/04/30 01:44:36 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.125 2011/04/27 07:55:14 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.126 2011/04/30 01:44:36 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_raid_diagnostic.h"
@@ -118,7 +118,6 @@
#endif
/* rad == RF_RaidAccessDesc_t */
-RF_DECLARE_MUTEX(rf_rad_lock)
#define RF_MAX_FREE_RAD 128
#define RF_MIN_FREE_RAD 32
@@ -134,7 +133,7 @@
static void rf_ShutdownRDFreeList(void *);
static int rf_ConfigureRDFreeList(RF_ShutdownList_t **);
-RF_DECLARE_MUTEX(rf_printf_mutex) /* debug only: avoids interleaved
+rf_declare_mutex2(rf_printf_mutex); /* debug only: avoids interleaved
* printfs by different stripes */
#define SIGNAL_QUIESCENT_COND(_raid_) wakeup(&((_raid_)->accesses_suspended))
@@ -213,16 +212,16 @@
* cuts down on the amount of serialization we've got going
* on.
*/
- RF_LOCK_MUTEX(rf_rad_lock);
+ rf_lock_mutex2(raidPtr->rad_lock);
if (raidPtr->waitShutdown) {
- RF_UNLOCK_MUTEX(rf_rad_lock);
+ rf_unlock_mutex2(raidPtr->rad_lock);
return (EBUSY);
}
raidPtr->waitShutdown = 1;
while (raidPtr->nAccOutstanding) {
- RF_WAIT_COND(raidPtr->outstandingCond, rf_rad_lock);
+ rf_wait_cond2(raidPtr->outstandingCond, raidPtr->rad_lock);
}
- RF_UNLOCK_MUTEX(rf_rad_lock);
+ rf_unlock_mutex2(raidPtr->rad_lock);
/* Wait for any parity re-writes to stop... */
while (raidPtr->parity_rewrite_in_progress) {
@@ -253,6 +252,9 @@
rf_ShutdownList(&raidPtr->shutdownList);
+ rf_destroy_cond2(raidPtr->outstandingCond);
+ rf_destroy_mutex2(raidPtr->rad_lock);
+
rf_UnconfigureArray();
return (0);
@@ -299,7 +301,7 @@
rf_lock_mutex2(configureMutex);
configureCount++;
if (isconfigged == 0) {
- rf_mutex_init(&rf_printf_mutex);
+ rf_init_mutex2(rf_printf_mutex, IPL_VM);
/* initialize globals */
@@ -353,7 +355,8 @@
DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine);
DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks);
- raidPtr->outstandingCond = 0;
+ rf_init_cond2(raidPtr->outstandingCond, "rfocond");
+ rf_init_mutex2(raidPtr->rad_lock, IPL_VM);
raidPtr->nAccOutstanding = 0;
raidPtr->waitShutdown = 0;
@@ -544,7 +547,6 @@
rf_pool_init(&rf_pools.rad, sizeof(RF_RaidAccessDesc_t),
"rf_rad_pl", RF_MIN_FREE_RAD, RF_MAX_FREE_RAD);
rf_ShutdownCreate(listp, rf_ShutdownRDFreeList, NULL);
- simple_lock_init(&rf_rad_lock);
return (0);
}
@@ -558,20 +560,20 @@
desc = pool_get(&rf_pools.rad, PR_WAITOK);
- RF_LOCK_MUTEX(rf_rad_lock);
+ rf_lock_mutex2(raidPtr->rad_lock);
if (raidPtr->waitShutdown) {
/*
* Actually, we're shutting the array down. Free the desc
* and return NULL.
*/
- RF_UNLOCK_MUTEX(rf_rad_lock);
+ rf_unlock_mutex2(raidPtr->rad_lock);
pool_put(&rf_pools.rad, desc);
return (NULL);
}
raidPtr->nAccOutstanding++;
- RF_UNLOCK_MUTEX(rf_rad_lock);
+ rf_unlock_mutex2(raidPtr->rad_lock);
desc->raidPtr = (void *) raidPtr;
desc->type = type;
@@ -628,12 +630,12 @@
}
pool_put(&rf_pools.rad, desc);
- RF_LOCK_MUTEX(rf_rad_lock);
+ rf_lock_mutex2(raidPtr->rad_lock);
raidPtr->nAccOutstanding--;
if (raidPtr->waitShutdown) {
- RF_SIGNAL_COND(raidPtr->outstandingCond);
+ rf_signal_cond2(raidPtr->outstandingCond);
}
- RF_UNLOCK_MUTEX(rf_rad_lock);
+ rf_unlock_mutex2(raidPtr->rad_lock);
}
/*********************************************************************
* Main routine for performing an access.
diff -r 0e3d6ef75d58 -r d39f1ecb90f6 sys/dev/raidframe/rf_driver.h
--- a/sys/dev/raidframe/rf_driver.h Sat Apr 30 01:10:07 2011 +0000
+++ b/sys/dev/raidframe/rf_driver.h Sat Apr 30 01:44:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.h,v 1.18 2011/04/27 07:55:15 mrg Exp $ */
+/* $NetBSD: rf_driver.h,v 1.19 2011/04/30 01:44:36 mrg Exp $ */
/*
* rf_driver.h
*/
@@ -41,7 +41,7 @@
#define RF_RETRY_THRESHOLD 5
#endif
-extern RF_DECLARE_MUTEX(rf_printf_mutex);
+extern rf_declare_mutex2(rf_printf_mutex);
int rf_BootRaidframe(void);
int rf_UnbootRaidframe(void);
int rf_Shutdown(RF_Raid_t *);
diff -r 0e3d6ef75d58 -r d39f1ecb90f6 sys/dev/raidframe/rf_mcpair.c
--- a/sys/dev/raidframe/rf_mcpair.c Sat Apr 30 01:10:07 2011 +0000
+++ b/sys/dev/raidframe/rf_mcpair.c Sat Apr 30 01:44:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_mcpair.c,v 1.22 2009/03/15 17:17:23 cegger Exp $ */
+/* $NetBSD: rf_mcpair.c,v 1.23 2011/04/30 01:44:36 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.22 2009/03/15 17:17:23 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.23 2011/04/30 01:44:36 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -75,7 +75,7 @@
RF_MCPair_t *t;
t = pool_get(&rf_pools.mcpair, PR_WAITOK);
- simple_lock_init(&t->mutex);
+ rf_mutex_init(&t->mutex);
t->cond = 0;
t->flag = 0;
diff -r 0e3d6ef75d58 -r d39f1ecb90f6 sys/dev/raidframe/rf_raid.h
--- a/sys/dev/raidframe/rf_raid.h Sat Apr 30 01:10:07 2011 +0000
+++ b/sys/dev/raidframe/rf_raid.h Sat Apr 30 01:44:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_raid.h,v 1.40 2011/04/27 07:55:15 mrg Exp $ */
+/* $NetBSD: rf_raid.h,v 1.41 2011/04/30 01:44:36 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -249,7 +249,8 @@
* for a per-array piece of data, but otherwise, it'd be an extra
* per-array lock, and that'd only be less efficient...)
*/
- RF_DECLARE_COND(outstandingCond)
+ rf_declare_mutex2(rad_lock);
+ rf_declare_cond2(outstandingCond);
int waitShutdown;
int nAccOutstanding;
diff -r 0e3d6ef75d58 -r d39f1ecb90f6 sys/dev/raidframe/rf_reconutil.c
--- a/sys/dev/raidframe/rf_reconutil.c Sat Apr 30 01:10:07 2011 +0000
+++ b/sys/dev/raidframe/rf_reconutil.c Sat Apr 30 01:44:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_reconutil.c,v 1.28 2007/03/04 06:02:39 christos Exp $ */
+/* $NetBSD: rf_reconutil.c,v 1.29 2011/04/30 01:44:36 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -31,7 +31,7 @@
********************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.28 2007/03/04 06:02:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.29 2011/04/30 01:44:36 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -125,13 +125,13 @@
}
/* initialize the event queue */
- simple_lock_init(&reconCtrlPtr->eq_mutex);
+ rf_mutex_init(&reconCtrlPtr->eq_mutex);
reconCtrlPtr->eventQueue = NULL;
reconCtrlPtr->eq_count = 0;
/* make the floating recon buffers and append them to the free list */
- simple_lock_init(&reconCtrlPtr->rb_mutex);
+ rf_mutex_init(&reconCtrlPtr->rb_mutex);
reconCtrlPtr->fullBufferList = NULL;
reconCtrlPtr->floatingRbufs = NULL;
diff -r 0e3d6ef75d58 -r d39f1ecb90f6 sys/dev/raidframe/rf_stripelocks.c
--- a/sys/dev/raidframe/rf_stripelocks.c Sat Apr 30 01:10:07 2011 +0000
+++ b/sys/dev/raidframe/rf_stripelocks.c Sat Apr 30 01:44:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_stripelocks.c,v 1.30 2009/03/15 17:17:23 cegger Exp $ */
+/* $NetBSD: rf_stripelocks.c,v 1.31 2011/04/30 01:44:36 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.30 2009/03/15 17:17:23 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.31 2011/04/30 01:44:36 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -658,7 +658,7 @@
RF_StripeLockDesc_t *p;
RF_LockReqDesc_t *q;
- RF_LOCK_MUTEX(rf_printf_mutex);
+ rf_lock_mutex2(rf_printf_mutex);
printf("Locked stripes:\n");
for (i = 0; i < rf_lockTableSize; i++)
if (lockTable[i].descList) {
@@ -714,6 +714,6 @@
printf("(none)\n");
else
printf("\n");
- RF_UNLOCK_MUTEX(rf_printf_mutex);
+ rf_unlock_mutex2(rf_printf_mutex);
}
#endif
diff -r 0e3d6ef75d58 -r d39f1ecb90f6 sys/dev/raidframe/rf_threadstuff.h
--- a/sys/dev/raidframe/rf_threadstuff.h Sat Apr 30 01:10:07 2011 +0000
+++ b/sys/dev/raidframe/rf_threadstuff.h Sat Apr 30 01:44:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_threadstuff.h,v 1.25 2011/04/27 07:55:15 mrg Exp $ */
+/* $NetBSD: rf_threadstuff.h,v 1.26 2011/04/30 01:44:36 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -70,6 +70,8 @@
#define RF_SIGNAL_COND(_c_) wakeup_one(&(_c_))
#define RF_BROADCAST_COND(_c_) wakeup(&(_c_))
+#define rf_mutex_init(m) simple_lock_init(m)
+
/* Modern mutex */
/* Note that rf_declare_{mutex,cond}2() do _NOT_ append the ; */
@@ -102,6 +104,4 @@
kthread_create(PRI_NONE, 0, NULL, (void (*)(void *))(_func_), \
(void *)(_arg_), &(_handle_), _fmt_, _fmt_arg_)
-#define rf_mutex_init(m) simple_lock_init(m)
-
#endif /* !_RF__RF_THREADSTUFF_H_ */
Home |
Main Index |
Thread Index |
Old Index