Module Name:    src
Committed By:   riz
Date:           Fri Jan  7 23:27:52 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1511):
        sys/dev/raidframe/rf_netbsdkintf.c: revision 1.278
add a hack to fix up old labels that do not have zero's in numBlocksHi:
if the total sectors reported (via disklabel or otherwise) is smaller
than 2^32, but numBlocksHi is set, zero it out instead.
tested by myself and christos, should fix reports of weirdness seen.


To generate a diff of this commit:
cvs rdiff -u -r1.250.4.9 -r1.250.4.10 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_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.9 src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.10
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.9	Fri Jan  7 23:25:59 2011
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Fri Jan  7 23:27:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.9 2011/01/07 23:25:59 riz Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.10 2011/01/07 23:27:51 riz 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.9 2011/01/07 23:25:59 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.10 2011/01/07 23:27:51 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -329,6 +329,7 @@
 void rf_cleanup_config_set(RF_ConfigSet_t *);
 int rf_have_enough_components(RF_ConfigSet_t *);
 int rf_auto_config_set(RF_ConfigSet_t *, int *);
+static void rf_fix_old_label_size(RF_ComponentLabel_t *, uint64_t);
 
 static int raidautoconfig = 0; /* Debugging, mostly.  Set to 0 to not
 				  allow autoconfig to take place.
@@ -2947,6 +2948,7 @@
 		/* Got the label.  Does it look reasonable? */
 		if (rf_reasonable_label(clabel) && 
 		    (clabel->partitionSize <= size)) {
+			rf_fix_old_label_size(clabel, numsecs);
 #ifdef DEBUG
 			printf("Component on: %s: %llu\n",
 				cname, (unsigned long long)size);
@@ -3153,6 +3155,24 @@
 }
 
 
+/*
+ * For reasons yet unknown, some old component labels have garbage in
+ * the newer numBlocksHi region, and this causes lossage.  Since those
+ * disks will also have numsecs set to less than 32 bits of sectors,
+ * we can determine when this corruption has occured, and fix it.
+ */
+static void
+rf_fix_old_label_size(RF_ComponentLabel_t *clabel, uint64_t numsecs)
+{
+
+	if (clabel->numBlocksHi && numsecs < ((uint64_t)1 << 32)) {
+		printf("WARNING: total sectors < 32 bits, yet numBlocksHi set\n"
+		       "WARNING: resetting numBlocksHi to zero.\n");
+		clabel->numBlocksHi = 0;
+	}
+}
+
+
 #ifdef DEBUG
 void
 rf_print_component_label(RF_ComponentLabel_t *clabel)

Reply via email to