tech-kern archive

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

Re: raidframe problem after upgrade



On Tue, Apr 26, 2011 at 08:00:04PM +1000, matthew green wrote:
> 
> > On Mon, Apr 25, 2011 at 08:44:51PM +0000, Michael van Elst wrote:
> > > bouyer%antioche.eu.org@localhost (Manuel Bouyer) writes:
> > > 
> > > >sd40e and sd80e are both part of raid8, raid15 should not be there. 
> > > >Also, the
> > > >size of the raid is wrong: it should be 514735MB and not 4709039MB
> > > >(500GB, not 4TB). 
> > > 
> > > 4709039MB = 514735MB + 4096*1024MB.
> > > 
> > > That's a badly initialized raid label (not disklabel).
> > 
> > OK; how can I get it working again ? This is a production server, there
> > are datas on this RAID ...
> 
> hmm, i thought i had sent this for pullup.  can you see if
> dev/raidframe/rf_netbsdkintf.c 1.284 helps?

rf_netbsdkintf.c 1.284 doesn't pullup cleanly, is anything else needed ?
1.284 uses rf_component_label_partitionsize() and
rf_component_label_numblocks() while netbsd-5 uses structure members.
I came up with the attached patch, untested for now. Can you confirm it's
OK ?

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
Index: rf_netbsdkintf.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_netbsdkintf.c,v
retrieving revision 1.250.4.10
diff -u -r1.250.4.10 rf_netbsdkintf.c
--- rf_netbsdkintf.c    7 Jan 2011 23:27:51 -0000       1.250.4.10
+++ rf_netbsdkintf.c    26 Apr 2011 10:34:03 -0000
@@ -139,7 +139,14 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.10 2011/01/07 23:27:51 
riz 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"
+#include "opt_raid_autoconfig.h"
+#include "raid.h"
+#endif
+>>>>>>> 1.284
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -321,7 +328,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);
@@ -2946,9 +2953,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) && 
                    (clabel->partitionSize <= size)) {
-                       rf_fix_old_label_size(clabel, numsecs);
 #ifdef DEBUG
                        printf("Component on: %s: %llu\n",
                                cname, (unsigned long long)size);
@@ -3133,7 +3139,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) ||
@@ -3148,7 +3154,11 @@
            clabel->column < clabel->num_columns &&
            clabel->blockSize > 0 &&
            clabel->numBlocks > 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);
@@ -3160,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