Module Name:    src
Committed By:   sborrill
Date:           Thu Nov 20 15:52:10 UTC 2014

Modified Files:
        src/sys/dev/raidframe [netbsd-5-1]: raidframevar.h rf_netbsdkintf.c
            rf_reconstruct.c

Log Message:
Pull up the following revisions(s) (requested by oster in ticket #1933):
        sys/dev/raidframe/raidframevar.h:       revision 1.17
        sys/dev/raidframe/rf_netbsdkintf.c:     revision 1.316
        sys/dev/raidframe/rf_reconstruct.c:     revision 1.121 via patch

Fix a long-standing bug related to rebooting while a reconstruct-to-spare
is underway but not yet complete. Fixes PR kern/49244.


To generate a diff of this commit:
cvs rdiff -u -r1.12.10.1 -r1.12.10.1.2.1 src/sys/dev/raidframe/raidframevar.h
cvs rdiff -u -r1.250.4.6 -r1.250.4.6.2.1 \
    src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.105.4.3 -r1.105.4.3.2.1 \
    src/sys/dev/raidframe/rf_reconstruct.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/raidframevar.h
diff -u src/sys/dev/raidframe/raidframevar.h:1.12.10.1 src/sys/dev/raidframe/raidframevar.h:1.12.10.1.2.1
--- src/sys/dev/raidframe/raidframevar.h:1.12.10.1	Thu Dec 10 22:59:16 2009
+++ src/sys/dev/raidframe/raidframevar.h	Thu Nov 20 15:52:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: raidframevar.h,v 1.12.10.1 2009/12/10 22:59:16 snj Exp $ */
+/*	$NetBSD: raidframevar.h,v 1.12.10.1.2.1 2014/11/20 15:52:10 sborrill Exp $ */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -384,17 +384,17 @@ struct RF_SparetWait_s {
  * IF YOU ADD A STATE, CHECK TO SEE IF YOU NEED TO MODIFY RF_DEAD_DISK().
  */
 enum RF_DiskStatus_e {
-        rf_ds_optimal,          /* no problems */
-        rf_ds_failed,           /* reconstruction ongoing */
-        rf_ds_reconstructing,   /* reconstruction complete to spare, dead disk
-                                 * not yet replaced */
-        rf_ds_dist_spared,      /* reconstruction complete to distributed
+	rf_ds_optimal,          /* no problems */
+	rf_ds_failed,           /* disk has failed */
+	rf_ds_reconstructing,   /* reconstruction ongoing */
+	rf_ds_dist_spared,      /* reconstruction complete to distributed
                                  * spare space, dead disk not yet replaced */
-        rf_ds_spared,           /* reconstruction complete to distributed
-                                 * spare space, dead disk not yet replaced */
-        rf_ds_spare,            /* an available spare disk */
-        rf_ds_used_spare        /* a spare which has been used, and hence is
+	rf_ds_spared,           /* reconstruction complete, dead disk not 
+				   yet replaced */
+	rf_ds_spare,            /* an available spare disk */
+	rf_ds_used_spare,       /* a spare which has been used, and hence is
                                  * not available */
+	rf_ds_rebuilding_spare	/* a spare which is being rebuilt to */
 };
 typedef enum RF_DiskStatus_e RF_DiskStatus_t;
 

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.6 src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.6.2.1
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.6	Sat Mar  6 20:56:15 2010
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Thu Nov 20 15:52:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.6 2010/03/06 20:56:15 sborrill Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.6.2.1 2014/11/20 15:52:10 sborrill Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.6 2010/03/06 20:56:15 sborrill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.6.2.1 2014/11/20 15:52:10 sborrill Exp $");
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -1470,6 +1470,10 @@ raidioctl(dev_t dev, u_long cmd, void *d
 		}
 		for (j = d_cfg->cols, i = 0; i < d_cfg->nspares; i++, j++) {
 			d_cfg->spares[i] = raidPtr->Disks[j];
+			if (d_cfg->spares[i].status == rf_ds_rebuilding_spare) {
+				/* XXX: raidctl(8) expects to see this as a used spare */
+				d_cfg->spares[i].status = rf_ds_used_spare;
+			}
 		}
 		retcode = copyout(d_cfg, *ucfgp, sizeof(RF_DeviceConfig_t));
 		RF_Free(d_cfg, sizeof(RF_DeviceConfig_t));

Index: src/sys/dev/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.3 src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.3.2.1
--- src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.3	Thu Dec 10 22:59:17 2009
+++ src/sys/dev/raidframe/rf_reconstruct.c	Thu Nov 20 15:52:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.105.4.3 2009/12/10 22:59:17 snj Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.105.4.3.2.1 2014/11/20 15:52:10 sborrill 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.105.4.3 2009/12/10 22:59:17 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.105.4.3.2.1 2014/11/20 15:52:10 sborrill Exp $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -259,7 +259,7 @@ rf_ReconstructFailedDiskBasic(RF_Raid_t 
 		for (scol = raidPtr->numCol; scol < raidPtr->numCol + raidPtr->numSpare; scol++) {
 			if (raidPtr->Disks[scol].status == rf_ds_spare) {
 				spareDiskPtr = &raidPtr->Disks[scol];
-				spareDiskPtr->status = rf_ds_used_spare;
+				spareDiskPtr->status = rf_ds_rebuilding_spare;
 				break;
 			}
 		}
@@ -305,6 +305,13 @@ rf_ReconstructFailedDiskBasic(RF_Raid_t 
 		/* XXX doesn't hold for RAID 6!!*/
 
 		RF_LOCK_MUTEX(raidPtr->mutex);
+		/* The failed disk has already been marked as rf_ds_spared 
+		   (or rf_ds_dist_spared) in
+		   rf_ContinueReconstructFailedDisk() 
+		   so we just update the spare disk as being a used spare
+		*/
+
+		spareDiskPtr->status = rf_ds_used_spare;
 		raidPtr->parity_good = RF_RAID_CLEAN;
 		RF_UNLOCK_MUTEX(raidPtr->mutex);
 
@@ -479,7 +486,7 @@ rf_ReconstructInPlace(RF_Raid_t *raidPtr
 	RF_UNLOCK_MUTEX(raidPtr->mutex);
 
 	spareDiskPtr = &raidPtr->Disks[col];
-	spareDiskPtr->status = rf_ds_used_spare;
+	spareDiskPtr->status = rf_ds_rebuilding_spare;
 
 	printf("raid%d: initiating in-place reconstruction on column %d\n",
 	       raidPtr->raidid, col);

Reply via email to