Module Name:    src
Committed By:   mrg
Date:           Sat Dec 11 03:12:11 UTC 2010

Modified Files:
        src/sys/dev/raidframe: rf_netbsdkintf.c

Log Message:
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.277 -r1.278 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.277 src/sys/dev/raidframe/rf_netbsdkintf.c:1.278
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.277	Wed Dec  8 16:18:06 2010
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Sat Dec 11 03:12:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.277 2010/12/08 16:18:06 christos Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.278 2010/12/11 03:12:10 mrg 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.277 2010/12/08 16:18:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.278 2010/12/11 03:12:10 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -341,6 +341,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.
@@ -2985,6 +2986,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);
@@ -3193,6 +3195,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