Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe Improve and/or re-arrange a number of lock...



details:   https://anonhg.NetBSD.org/src/rev/5259a9b2762b
branches:  trunk
changeset: 538341:5259a9b2762b
user:      oster <oster%NetBSD.org@localhost>
date:      Fri Oct 18 02:46:36 2002 +0000

description:
Improve and/or re-arrange a number of locks.  While much of the locking is
still a mess, and there are a number of unresolved issues here, this
gets us closer to being happier in LOCKDEBUG land.

diffstat:

 sys/dev/raidframe/rf_driver.c      |   9 ++++++---
 sys/dev/raidframe/rf_reconstruct.c |  27 +++++++++++++++++++--------
 2 files changed, 25 insertions(+), 11 deletions(-)

diffs (190 lines):

diff -r 08c3da1e61ab -r 5259a9b2762b sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c     Fri Oct 18 01:59:27 2002 +0000
+++ b/sys/dev/raidframe/rf_driver.c     Fri Oct 18 02:46:36 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_driver.c,v 1.64 2002/10/04 20:05:14 oster Exp $     */
+/*     $NetBSD: rf_driver.c,v 1.65 2002/10/18 02:46:36 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.64 2002/10/04 20:05:14 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.65 2002/10/18 02:46:36 oster Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -711,20 +711,23 @@
        raidPtr->numFailures++;
        raidPtr->Disks[frow][fcol].status = rf_ds_failed;
        raidPtr->status[frow] = rf_rs_degraded;
+       RF_UNLOCK_MUTEX(raidPtr->mutex);
        rf_update_component_labels(raidPtr, RF_NORMAL_COMPONENT_UPDATE);
-       RF_UNLOCK_MUTEX(raidPtr->mutex);
 
        /* Close the component, so that it's not "locked" if someone 
           else want's to use it! */
 
        rf_close_component(raidPtr, raidPtr->raid_cinfo[frow][fcol].ci_vp,
                           raidPtr->Disks[frow][fcol].auto_configured);
+
+       RF_LOCK_MUTEX(raidPtr->mutex);
        raidPtr->raid_cinfo[frow][fcol].ci_vp = NULL;
 
        /* Need to mark the component as not being auto_configured 
           (in case it was previously). */
 
        raidPtr->Disks[frow][fcol].auto_configured = 0;
+       RF_UNLOCK_MUTEX(raidPtr->mutex);
 
        if (initRecon)
                rf_ReconstructFailedDisk(raidPtr, frow, fcol);
diff -r 08c3da1e61ab -r 5259a9b2762b sys/dev/raidframe/rf_reconstruct.c
--- a/sys/dev/raidframe/rf_reconstruct.c        Fri Oct 18 01:59:27 2002 +0000
+++ b/sys/dev/raidframe/rf_reconstruct.c        Fri Oct 18 02:46:36 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_reconstruct.c,v 1.47 2002/10/06 05:32:59 oster Exp $        */
+/*     $NetBSD: rf_reconstruct.c,v 1.48 2002/10/18 02:46:37 oster Exp $        */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  ************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.47 2002/10/06 05:32:59 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.48 2002/10/18 02:46:37 oster Exp $");
 
 #include <sys/time.h>
 #include <sys/buf.h>
@@ -363,7 +363,9 @@
 
                /* XXX doesn't hold for RAID 6!!*/
 
+               RF_LOCK_MUTEX(raidPtr->mutex);
                raidPtr->parity_good = RF_RAID_CLEAN;
+               RF_UNLOCK_MUTEX(raidPtr->mutex);
 
                /* XXXX MORE NEEDED HERE */
                
@@ -442,8 +444,10 @@
                        raidPtr->numFailures++;
                        raidPtr->Disks[row][col].status = rf_ds_failed;
                        raidPtr->status[row] = rf_rs_degraded;
+                       RF_UNLOCK_MUTEX(raidPtr->mutex);
                        rf_update_component_labels(raidPtr, 
                                                   RF_NORMAL_COMPONENT_UPDATE);
+                       RF_LOCK_MUTEX(raidPtr->mutex);
                }
 
                while (raidPtr->reconInProgress) {
@@ -483,7 +487,9 @@
 #endif
                        vp = raidPtr->raid_cinfo[row][col].ci_vp;
                        ac = raidPtr->Disks[row][col].auto_configured;
+                       RF_UNLOCK_MUTEX(raidPtr->mutex);
                        rf_close_component(raidPtr, vp, ac);
+                       RF_LOCK_MUTEX(raidPtr->mutex);
                        raidPtr->raid_cinfo[row][col].ci_vp = NULL;
                }
                /* note that this disk was *not* auto_configured (any longer)*/
@@ -493,16 +499,17 @@
                printf("About to (re-)open the device for rebuilding: %s\n",
                       raidPtr->Disks[row][col].devname);
 #endif
-               
+               RF_UNLOCK_MUTEX(raidPtr->mutex);
                retcode = raidlookup(raidPtr->Disks[row][col].devname, 
                                     proc, &vp);
-       
+
                if (retcode) {
                        printf("raid%d: rebuilding: raidlookup on device: %s failed: %d!\n",raidPtr->raidid,
                               raidPtr->Disks[row][col].devname, retcode);
 
                        /* the component isn't responding properly... 
                           must be still dead :-( */
+                       RF_LOCK_MUTEX(raidPtr->mutex);
                        raidPtr->reconInProgress--;
                        RF_UNLOCK_MUTEX(raidPtr->mutex);
                        return(retcode);
@@ -514,6 +521,7 @@
 
                        if ((retcode = VOP_GETATTR(vp, &va, proc->p_ucred, 
                                                   proc)) != 0) {
+                               RF_LOCK_MUTEX(raidPtr->mutex);
                                raidPtr->reconInProgress--;
                                RF_UNLOCK_MUTEX(raidPtr->mutex);
                                return(retcode);
@@ -521,10 +529,12 @@
                        retcode = VOP_IOCTL(vp, DIOCGPART, (caddr_t) & dpart,
                                            FREAD, proc->p_ucred, proc);
                        if (retcode) {
+                               RF_LOCK_MUTEX(raidPtr->mutex);
                                raidPtr->reconInProgress--;
                                RF_UNLOCK_MUTEX(raidPtr->mutex);
                                return(retcode);
                        }
+                       RF_LOCK_MUTEX(raidPtr->mutex);
                        raidPtr->Disks[row][col].blockSize =
                                dpart.disklab->d_secsize;
 
@@ -543,6 +553,7 @@
                        raidPtr->Disks[row][col].numBlocks =
                                raidPtr->Disks[row][col].numBlocks *
                                rf_sizePercentage / 100;
+                       RF_UNLOCK_MUTEX(raidPtr->mutex);
                }
 
 
@@ -555,8 +566,6 @@
                printf("raid%d:    row %d col %d -> spare at row %d col %d\n", 
                       raidPtr->raidid, row, col, row, col);
 
-               RF_UNLOCK_MUTEX(raidPtr->mutex);
-               
                reconDesc = AllocRaidReconDesc((void *) raidPtr, row, col, 
                                               spareDiskPtr, numDisksDone, 
                                               row, col);
@@ -580,14 +589,15 @@
                             lp->parityConfig);
                rc = EIO;
        }
-       RF_LOCK_MUTEX(raidPtr->mutex);
        
        if (!rc) {
+               RF_LOCK_MUTEX(raidPtr->mutex);
                /* Need to set these here, as at this point it'll be claiming
                   that the disk is in rf_ds_spared!  But we know better :-) */
                
                raidPtr->Disks[row][col].status = rf_ds_optimal;
                raidPtr->status[row] = rf_rs_optimal;
+               RF_UNLOCK_MUTEX(raidPtr->mutex);
                
                /* fix up the component label */
                /* Don't actually need the read here.. */
@@ -595,6 +605,7 @@
                                         raidPtr->raid_cinfo[row][col].ci_vp,
                                         &c_label);
 
+               RF_LOCK_MUTEX(raidPtr->mutex);
                raid_init_component_label(raidPtr, &c_label);
 
                c_label.row = row;
@@ -607,13 +618,13 @@
                /* XXX doesn't hold for RAID 6!!*/
 
                raidPtr->parity_good = RF_RAID_CLEAN;
+               RF_UNLOCK_MUTEX(raidPtr->mutex);
        
                raidwrite_component_label(raidPtr->raid_cinfo[row][col].ci_dev,
                                          raidPtr->raid_cinfo[row][col].ci_vp,
                                          &c_label);
 
        }
-       RF_UNLOCK_MUTEX(raidPtr->mutex);
        RF_SIGNAL_COND(raidPtr->waitForReconCond);
        return (rc);
 }



Home | Main Index | Thread Index | Old Index