Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/raidframe fix a problem in half-configured raid devi...



details:   https://anonhg.NetBSD.org/src/rev/4a349d88fb14
branches:  trunk
changeset: 782354:4a349d88fb14
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Oct 30 00:33:11 2012 +0000

description:
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:

 sys/dev/raidframe/rf_driver.c |  64 +++++++++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 23 deletions(-)

diffs (127 lines):

diff -r e7c2ef22fd26 -r 4a349d88fb14 sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c     Mon Oct 29 23:45:34 2012 +0000
+++ b/sys/dev/raidframe/rf_driver.c     Tue Oct 30 00:33:11 2012 +0000
@@ -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 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_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_FreeEmergBuffers(raidPtr); \
        rf_ShutdownList(&raidPtr->shutdownList); \
        rf_UnconfigureArray(); \
+       rf_destroy_mutex_cond(raidPtr); \
 }
 
 #define DO_RAID_INIT_CONFIGURE(f) { \
@@ -341,7 +335,8 @@
        }
        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 @@
        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 @@
        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_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);
+}



Home | Main Index | Thread Index | Old Index