Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe apply the fix_label hack to partitionSizeH...



details:   https://anonhg.NetBSD.org/src/rev/385aa31c3823
branches:  trunk
changeset: 763421:385aa31c3823
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Mar 18 23:53:26 2011 +0000

description:
apply the fix_label hack to partitionSizeHi as well.  it's needed there.
to do so, move the call to fix the label inside of rf_reasonable_label()
itself, so we can fix the partition sizes before calling
rf_component_label_partitionsize() itself.

fixes the failure mode where i had garbage not in numBlocksHi but in
partitionSizeHi, and the check against rf_component_label_partitionsize()
would fail and my raid would not auto-configure.

diffstat:

 sys/dev/raidframe/rf_netbsdkintf.c |  38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)

diffs (93 lines):

diff -r b4f7d44a7441 -r 385aa31c3823 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Fri Mar 18 23:32:01 2011 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Fri Mar 18 23:53:26 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.283 2011/03/04 17:45:17 oster Exp $       */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.284 2011/03/18 23:53:26 mrg 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.283 2011/03/04 17:45:17 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.284 2011/03/18 23:53:26 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -295,7 +295,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 *);
+static 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);
@@ -2948,9 +2948,8 @@
 
        if (!raidread_component_label(secsize, dev, vp, clabel)) {
                /* Got the label.  Does it look reasonable? */
-               if (rf_reasonable_label(clabel) && 
+               if (rf_reasonable_label(clabel, numsecs) && 
                    (rf_component_label_partitionsize(clabel) <= size)) {
-                       rf_fix_old_label_size(clabel, numsecs);
 #ifdef DEBUG
                        printf("Component on: %s: %llu\n",
                                cname, (unsigned long long)size);
@@ -3135,7 +3134,7 @@
 
 
 static int
-rf_reasonable_label(RF_ComponentLabel_t *clabel)
+rf_reasonable_label(RF_ComponentLabel_t *clabel, uint64_t numsecs)
 {
 
        if (((clabel->version==RF_COMPONENT_LABEL_VERSION_1) ||
@@ -3155,7 +3154,11 @@
             * rf_fix_old_label_size() will fix it.
             */
            rf_component_label_numblocks(clabel) > 0) {
-               /* label looks reasonable enough... */
+               /*
+                * label looks reasonable enough...
+                * let's make sure it has no old garbage.
+                */
+               rf_fix_old_label_size(clabel, numsecs);
                return(1);
        }
        return(0);
@@ -3167,15 +3170,28 @@
  * 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.
+ *
+ * The exact same problem, with the same unknown reason, happens to
+ * the partitionSizeHi member as well.
  */
 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;
+       if (numsecs < ((uint64_t)1 << 32)) {
+               if (clabel->numBlocksHi) {
+                       printf("WARNING: total sectors < 32 bits, yet "
+                              "numBlocksHi set\n"
+                              "WARNING: resetting numBlocksHi to zero.\n");
+                       clabel->numBlocksHi = 0;
+               }
+
+               if (clabel->partitionSizeHi) {
+                       printf("WARNING: total sectors < 32 bits, yet "
+                              "partitionSizeHi set\n"
+                              "WARNING: resetting partitionSizeHi to zero.\n");
+                       clabel->partitionSizeHi = 0;
+               }
        }
 }
 



Home | Main Index | Thread Index | Old Index