summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>2012-10-30 00:33:11 +0000
committermrg <mrg@NetBSD.org>2012-10-30 00:33:11 +0000
commitefd10310458e3ecfd06362b6376536b7cdb669ae (patch)
treeeebb46b0b86fece4574ad2d372b1a9d026bddd5d /sys/dev/raidframe
parent9515116e90d65a945e03c2922ce72455b11d1081 (diff)
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.
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_driver.c64
1 files changed, 41 insertions, 23 deletions
diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c
index 102cdf10373..ebe26d6e7bb 100644
--- a/sys/dev/raidframe/rf_driver.c
+++ b/sys/dev/raidframe/rf_driver.c
@@ -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; /* non array-specific
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_Config_t *cfgPtr, RF_AutoConfig_t *ac)
}
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_Config_t *cfgPtr, RF_AutoConfig_t *ac)
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_Config_t *cfgPtr, RF_AutoConfig_t *ac)
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 char *file, int line, int rc)
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);
+}