Module Name: src
Committed By: mrg
Date: Tue Oct 30 00:33:11 UTC 2012
Modified Files:
src/sys/dev/raidframe: rf_driver.c
Log Message:
fix a problem in half-configured raid devices, found when a "raidctl -c"
failed, and a "raidctl -C" was run afterwards, triggering mutex locking
issues. fix this by moving alloc and destroy of mutex/condvar for a
raid device into separate functions, and call the destroy function from
the DO_RAID_FAIL() macro.
probably needs a netbsd-6 pullup. sigh.
To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/dev/raidframe/rf_driver.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.129 src/sys/dev/raidframe/rf_driver.c:1.130
--- src/sys/dev/raidframe/rf_driver.c:1.129 Fri May 27 22:48:24 2011
+++ src/sys/dev/raidframe/rf_driver.c Tue Oct 30 00:33:11 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.c,v 1.129 2011/05/27 22:48:24 yamt Exp $ */
+/* $NetBSD: rf_driver.c,v 1.130 2012/10/30 00:33:11 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.129 2011/05/27 22:48:24 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.130 2012/10/30 00:33:11 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_raid_diagnostic.h"
@@ -153,6 +153,8 @@ static RF_ShutdownList_t *globalShutdown
static int rf_ConfigureRDFreeList(RF_ShutdownList_t ** listp);
static int rf_AllocEmergBuffers(RF_Raid_t *);
static void rf_FreeEmergBuffers(RF_Raid_t *);
+static void rf_destroy_mutex_cond(RF_Raid_t *);
+static void rf_alloc_mutex_cond(RF_Raid_t *);
/* called at system boot time */
int
@@ -255,16 +257,7 @@ rf_Shutdown(RF_Raid_t *raidPtr)
rf_ShutdownList(&raidPtr->shutdownList);
- rf_destroy_cond2(raidPtr->waitForReconCond);
- rf_destroy_cond2(raidPtr->adding_hot_spare_cv);
-
- 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);
-
- rf_destroy_mutex2(raidPtr->mutex);
+ rf_destroy_mutex_cond(raidPtr);
rf_UnconfigureArray();
@@ -289,6 +282,7 @@ rf_Shutdown(RF_Raid_t *raidPtr)
rf_FreeEmergBuffers(raidPtr); \
rf_ShutdownList(&raidPtr->shutdownList); \
rf_UnconfigureArray(); \
+ rf_destroy_mutex_cond(raidPtr); \
}
#define DO_RAID_INIT_CONFIGURE(f) { \
@@ -341,7 +335,8 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Conf
}
rf_unlock_mutex2(configureMutex);
- rf_init_mutex2(raidPtr->mutex, IPL_VM);
+ rf_alloc_mutex_cond(raidPtr);
+
/* set up the cleanup list. Do this after ConfigureDebug so that
* value of memDebug will be set */
@@ -363,17 +358,9 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Conf
DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine);
DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks);
- rf_init_cond2(raidPtr->outstandingCond, "rfocond");
- rf_init_mutex2(raidPtr->rad_lock, IPL_VM);
-
raidPtr->nAccOutstanding = 0;
raidPtr->waitShutdown = 0;
- rf_init_mutex2(raidPtr->access_suspend_mutex, IPL_VM);
- rf_init_cond2(raidPtr->access_suspend_cv, "rfquiesce");
-
- rf_init_cond2(raidPtr->waitForReconCond, "rfrcnw");
-
if (ac!=NULL) {
/* We have an AutoConfig structure.. Don't do the
normal disk configuration... call the auto config
@@ -406,8 +393,6 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Conf
raidPtr->adding_hot_spare = 0;
raidPtr->recon_in_progress = 0;
- rf_init_cond2(raidPtr->adding_hot_spare_cv, "raidhs");
-
raidPtr->maxOutstanding = cfgPtr->maxOutstandingDiskReqs;
/* autoconfigure and root_partition will actually get filled in
@@ -925,3 +910,36 @@ rf_print_unable_to_add_shutdown(const ch
RF_ERRORMSG3("Unable to add to shutdown list file %s line %d rc=%d\n",
file, line, rc);
}
+
+static void
+rf_alloc_mutex_cond(RF_Raid_t *raidPtr)
+{
+
+ rf_init_mutex2(raidPtr->mutex, IPL_VM);
+
+ rf_init_cond2(raidPtr->outstandingCond, "rfocond");
+ rf_init_mutex2(raidPtr->rad_lock, IPL_VM);
+
+ rf_init_mutex2(raidPtr->access_suspend_mutex, IPL_VM);
+ rf_init_cond2(raidPtr->access_suspend_cv, "rfquiesce");
+
+ rf_init_cond2(raidPtr->waitForReconCond, "rfrcnw");
+
+ rf_init_cond2(raidPtr->adding_hot_spare_cv, "raidhs");
+}
+
+static void
+rf_destroy_mutex_cond(RF_Raid_t *raidPtr)
+{
+
+ rf_destroy_cond2(raidPtr->waitForReconCond);
+ rf_destroy_cond2(raidPtr->adding_hot_spare_cv);
+
+ 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);
+
+ rf_destroy_mutex2(raidPtr->mutex);
+}