Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe add a hack to fix up old labels that do no...



details:   https://anonhg.NetBSD.org/src/rev/16fb6e3efb3a
branches:  trunk
changeset: 759469:16fb6e3efb3a
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Dec 11 03:12:10 2010 +0000

description:
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.

diffstat:

 sys/dev/raidframe/rf_netbsdkintf.c |  24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diffs (59 lines):

diff -r 68afece369c0 -r 16fb6e3efb3a sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Fri Dec 10 21:27:21 2010 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Sat Dec 11 03:12:10 2010 +0000
@@ -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)



Home | Main Index | Thread Index | Old Index