Module Name:    src
Committed By:   oster
Date:           Fri Jul 29 19:55:51 UTC 2011

Modified Files:
        src/sys/dev/raidframe: rf_disks.c rf_kintf.h rf_netbsdkintf.c

Log Message:
In rf_disks.c make sure ser_values and ser_count arrays are
initialized before use.

Validate the component label before considering a component for use,
and make sure we only consider components that are optimal.

Fixes PR#44251.  All atf RAIDframe tests now pass.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/raidframe/rf_disks.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/raidframe/rf_kintf.h
cvs rdiff -u -r1.291 -r1.292 src/sys/dev/raidframe/rf_netbsdkintf.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/rf_disks.c
diff -u src/sys/dev/raidframe/rf_disks.c:1.79 src/sys/dev/raidframe/rf_disks.c:1.80
--- src/sys/dev/raidframe/rf_disks.c:1.79	Wed May 11 18:13:12 2011
+++ src/sys/dev/raidframe/rf_disks.c	Fri Jul 29 19:55:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_disks.c,v 1.79 2011/05/11 18:13:12 mrg Exp $	*/
+/*	$NetBSD: rf_disks.c,v 1.80 2011/07/29 19:55:50 oster Exp $	*/
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -60,7 +60,7 @@
  ***************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.79 2011/05/11 18:13:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.80 2011/07/29 19:55:50 oster Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -136,6 +136,11 @@
 			ret = raidfetch_component_label(raidPtr, c);
 			if (ret)
 				goto fail;
+
+			/* mark it as failed if the label looks bogus... */
+			if (!rf_reasonable_label(&raidPtr->raid_cinfo[c].ci_label,0) && !force) {
+				disks[c].status = rf_ds_failed;
+			}
 		}
 
 		if (disks[c].status != rf_ds_optimal) {
@@ -749,7 +754,12 @@
 	num_ser = 0;
 	num_mod = 0;
 
+	ser_values[0] = ser_values[1] = ser_values[2] = ser_values[3] = 0;
+	ser_count[0] = ser_count[1] = ser_count[2] = ser_count[3] = 0;
+
 	for (c = 0; c < raidPtr->numCol; c++) {
+		if (raidPtr->Disks[c].status != rf_ds_optimal)
+			continue;
 		ci_label = raidget_component_label(raidPtr, c);
 		found=0;
 		for(i=0;i<num_ser;i++) {
@@ -805,6 +815,8 @@
 			}
 
 			for (c = 0; c < raidPtr->numCol; c++) {
+				if (raidPtr->Disks[c].status != rf_ds_optimal)
+					continue;
 				ci_label = raidget_component_label(raidPtr, c);
 				if (serial_number != ci_label->serial_number) {
 					hosed_column = c;
@@ -860,6 +872,9 @@
 			}
 
 			for (c = 0; c < raidPtr->numCol; c++) {
+				if (raidPtr->Disks[c].status != rf_ds_optimal)
+					continue;
+
 				ci_label = raidget_component_label(raidPtr, c);
 				if (mod_number != ci_label->mod_counter) {
 					if (hosed_column == c) {
@@ -920,6 +935,13 @@
 		fatal_error = 1;
 	}
 
+        for (c = 0; c < raidPtr->numCol; c++) {
+		if (raidPtr->Disks[c].status != rf_ds_optimal) {
+			hosed_column = c;
+			break;
+		}
+	}
+
 	/* we start by assuming the parity will be good, and flee from
 	   that notion at the slightest sign of trouble */
 

Index: src/sys/dev/raidframe/rf_kintf.h
diff -u src/sys/dev/raidframe/rf_kintf.h:1.21 src/sys/dev/raidframe/rf_kintf.h:1.22
--- src/sys/dev/raidframe/rf_kintf.h:1.21	Tue Nov 17 18:54:26 2009
+++ src/sys/dev/raidframe/rf_kintf.h	Fri Jul 29 19:55:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_kintf.h,v 1.21 2009/11/17 18:54:26 jld Exp $	*/
+/*	$NetBSD: rf_kintf.h,v 1.22 2011/07/29 19:55:50 oster Exp $	*/
 /*
  * rf_kintf.h
  *
@@ -37,6 +37,8 @@
 #include <dev/raidframe/raidframevar.h>
 
 int     rf_GetSpareTableFromDaemon(RF_SparetWait_t * req);
+int rf_reasonable_label(RF_ComponentLabel_t *, uint64_t);
+
 
 void    raidstart(RF_Raid_t * raidPtr);
 int     rf_DispatchKernelIO(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req);

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.291 src/sys/dev/raidframe/rf_netbsdkintf.c:1.292
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.291	Wed May 11 18:13:12 2011
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Fri Jul 29 19:55:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.291 2011/05/11 18:13:12 mrg Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.292 2011/07/29 19:55:50 oster Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.291 2011/05/11 18:13:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.292 2011/07/29 19:55:50 oster Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -297,7 +297,7 @@
 RF_AutoConfig_t *rf_find_raid_components(void);
 RF_ConfigSet_t *rf_create_auto_sets(RF_AutoConfig_t *);
 static int rf_does_it_fit(RF_ConfigSet_t *,RF_AutoConfig_t *);
-static int rf_reasonable_label(RF_ComponentLabel_t *, uint64_t);
+int rf_reasonable_label(RF_ComponentLabel_t *, uint64_t);
 void rf_create_configuration(RF_AutoConfig_t *,RF_Config_t *, RF_Raid_t *);
 int rf_set_autoconfig(RF_Raid_t *, int);
 int rf_set_rootpartition(RF_Raid_t *, int);
@@ -3132,7 +3132,7 @@
 }
 
 
-static int
+int
 rf_reasonable_label(RF_ComponentLabel_t *clabel, uint64_t numsecs)
 {
 
@@ -3157,7 +3157,8 @@
 		 * label looks reasonable enough...
 		 * let's make sure it has no old garbage.
 		 */
-		rf_fix_old_label_size(clabel, numsecs);
+		if (numsecs)
+			rf_fix_old_label_size(clabel, numsecs);
 		return(1);
 	}
 	return(0);

Reply via email to