Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe Better protect hot-spare adding, and make ...



details:   https://anonhg.NetBSD.org/src/rev/0b4f082ed86d
branches:  trunk
changeset: 538521:0b4f082ed86d
user:      oster <oster%NetBSD.org@localhost>
date:      Tue Oct 22 03:15:28 2002 +0000

description:
Better protect hot-spare adding, and make it LOCKDEBUG friendly.

diffstat:

 sys/dev/raidframe/rf_disks.c  |  19 +++++++++++++++----
 sys/dev/raidframe/rf_driver.c |   5 +++--
 sys/dev/raidframe/rf_raid.h   |   3 ++-
 3 files changed, 20 insertions(+), 7 deletions(-)

diffs (101 lines):

diff -r a95e346f42bd -r 0b4f082ed86d sys/dev/raidframe/rf_disks.c
--- a/sys/dev/raidframe/rf_disks.c      Tue Oct 22 03:14:16 2002 +0000
+++ b/sys/dev/raidframe/rf_disks.c      Tue Oct 22 03:15:28 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_disks.c,v 1.39 2002/09/23 02:51:43 oster Exp $      */
+/*     $NetBSD: rf_disks.c,v 1.40 2002/10/22 03:15:28 oster Exp $      */
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -67,7 +67,7 @@
  ***************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.39 2002/09/23 02:51:43 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.40 2002/10/22 03:15:28 oster Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -1021,12 +1021,20 @@
        unsigned int bs;
        int spare_number;
 
+       ret=0;
+
        if (raidPtr->numSpare >= RF_MAXSPARE) {
                RF_ERRORMSG1("Too many spares: %d\n", raidPtr->numSpare);
                return(EINVAL);
        }
 
        RF_LOCK_MUTEX(raidPtr->mutex);
+       while (raidPtr->adding_hot_spare==1) {
+               ltsleep(&(raidPtr->adding_hot_spare), PRIBIO, "raidhs", 0,
+                       &(raidPtr->mutex));
+       }
+       raidPtr->adding_hot_spare=1;
+       RF_UNLOCK_MUTEX(raidPtr->mutex);
 
        /* the beginning of the spares... */
        disks = &raidPtr->Disks[0][raidPtr->numCol];
@@ -1090,13 +1098,16 @@
                                 &raidPtr->shutdownList,
                                 raidPtr->cleanupList);
                                 
-
+       RF_LOCK_MUTEX(raidPtr->mutex);
        raidPtr->numSpare++;
        RF_UNLOCK_MUTEX(raidPtr->mutex);
-       return (0);
 
 fail:
+       RF_LOCK_MUTEX(raidPtr->mutex);
+       raidPtr->adding_hot_spare=0;
+       wakeup(&(raidPtr->adding_hot_spare));
        RF_UNLOCK_MUTEX(raidPtr->mutex);
+
        return(ret);
 }
 
diff -r a95e346f42bd -r 0b4f082ed86d sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c     Tue Oct 22 03:14:16 2002 +0000
+++ b/sys/dev/raidframe/rf_driver.c     Tue Oct 22 03:15:28 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_driver.c,v 1.65 2002/10/18 02:46:36 oster Exp $     */
+/*     $NetBSD: rf_driver.c,v 1.66 2002/10/22 03:15:28 oster Exp $     */
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -73,7 +73,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.65 2002/10/18 02:46:36 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.66 2002/10/22 03:15:28 oster Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -449,6 +449,7 @@
        raidPtr->numNewFailures = 0;
        raidPtr->copyback_in_progress = 0;
        raidPtr->parity_rewrite_in_progress = 0;
+       raidPtr->adding_hot_spare = 0;
        raidPtr->recon_in_progress = 0;
        raidPtr->maxOutstanding = cfgPtr->maxOutstandingDiskReqs;
 
diff -r a95e346f42bd -r 0b4f082ed86d sys/dev/raidframe/rf_raid.h
--- a/sys/dev/raidframe/rf_raid.h       Tue Oct 22 03:14:16 2002 +0000
+++ b/sys/dev/raidframe/rf_raid.h       Tue Oct 22 03:15:28 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_raid.h,v 1.16 2002/10/11 02:10:08 oster Exp $       */
+/*     $NetBSD: rf_raid.h,v 1.17 2002/10/22 03:15:28 oster Exp $       */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -209,6 +209,7 @@
        int     recon_in_progress;
        int     parity_rewrite_in_progress;
        int     copyback_in_progress;
+       int     adding_hot_spare;
 
        /*
          * Engine thread control



Home | Main Index | Thread Index | Old Index