Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe In rf_disks.c make sure ser_values and ser...



details:   https://anonhg.NetBSD.org/src/rev/1aad680ee6f4
branches:  trunk
changeset: 767755:1aad680ee6f4
user:      oster <oster%NetBSD.org@localhost>
date:      Fri Jul 29 19:55:50 2011 +0000

description:
In rf_disks.c make sure ser_values and ser_count arrays are
initialized before use.

Validate the component label before considering a component for use,
and make sure we only consider components that are optimal.

Fixes PR#44251.  All atf RAIDframe tests now pass.

diffstat:

 sys/dev/raidframe/rf_disks.c       |  26 ++++++++++++++++++++++++--
 sys/dev/raidframe/rf_kintf.h       |   4 +++-
 sys/dev/raidframe/rf_netbsdkintf.c |  11 ++++++-----
 3 files changed, 33 insertions(+), 8 deletions(-)

diffs (140 lines):

diff -r 721f862a9c44 -r 1aad680ee6f4 sys/dev/raidframe/rf_disks.c
--- a/sys/dev/raidframe/rf_disks.c      Fri Jul 29 19:19:14 2011 +0000
+++ b/sys/dev/raidframe/rf_disks.c      Fri Jul 29 19:55:50 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_disks.c,v 1.79 2011/05/11 18:13:12 mrg Exp $        */
+/*     $NetBSD: rf_disks.c,v 1.80 2011/07/29 19:55:50 oster Exp $      */
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -60,7 +60,7 @@
  ***************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.79 2011/05/11 18:13:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.80 2011/07/29 19:55:50 oster Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -136,6 +136,11 @@
                        ret = raidfetch_component_label(raidPtr, c);
                        if (ret)
                                goto fail;
+
+                       /* mark it as failed if the label looks bogus... */
+                       if (!rf_reasonable_label(&raidPtr->raid_cinfo[c].ci_label,0) && !force) {
+                               disks[c].status = rf_ds_failed;
+                       }
                }
 
                if (disks[c].status != rf_ds_optimal) {
@@ -749,7 +754,12 @@
        num_ser = 0;
        num_mod = 0;
 
+       ser_values[0] = ser_values[1] = ser_values[2] = ser_values[3] = 0;
+       ser_count[0] = ser_count[1] = ser_count[2] = ser_count[3] = 0;
+
        for (c = 0; c < raidPtr->numCol; c++) {
+               if (raidPtr->Disks[c].status != rf_ds_optimal)
+                       continue;
                ci_label = raidget_component_label(raidPtr, c);
                found=0;
                for(i=0;i<num_ser;i++) {
@@ -805,6 +815,8 @@
                        }
 
                        for (c = 0; c < raidPtr->numCol; c++) {
+                               if (raidPtr->Disks[c].status != rf_ds_optimal)
+                                       continue;
                                ci_label = raidget_component_label(raidPtr, c);
                                if (serial_number != ci_label->serial_number) {
                                        hosed_column = c;
@@ -860,6 +872,9 @@
                        }
 
                        for (c = 0; c < raidPtr->numCol; c++) {
+                               if (raidPtr->Disks[c].status != rf_ds_optimal)
+                                       continue;
+
                                ci_label = raidget_component_label(raidPtr, c);
                                if (mod_number != ci_label->mod_counter) {
                                        if (hosed_column == c) {
@@ -920,6 +935,13 @@
                fatal_error = 1;
        }
 
+        for (c = 0; c < raidPtr->numCol; c++) {
+               if (raidPtr->Disks[c].status != rf_ds_optimal) {
+                       hosed_column = c;
+                       break;
+               }
+       }
+
        /* we start by assuming the parity will be good, and flee from
           that notion at the slightest sign of trouble */
 
diff -r 721f862a9c44 -r 1aad680ee6f4 sys/dev/raidframe/rf_kintf.h
--- a/sys/dev/raidframe/rf_kintf.h      Fri Jul 29 19:19:14 2011 +0000
+++ b/sys/dev/raidframe/rf_kintf.h      Fri Jul 29 19:55:50 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_kintf.h,v 1.21 2009/11/17 18:54:26 jld Exp $        */
+/*     $NetBSD: rf_kintf.h,v 1.22 2011/07/29 19:55:50 oster Exp $      */
 /*
  * rf_kintf.h
  *
@@ -37,6 +37,8 @@
 #include <dev/raidframe/raidframevar.h>
 
 int     rf_GetSpareTableFromDaemon(RF_SparetWait_t * req);
+int rf_reasonable_label(RF_ComponentLabel_t *, uint64_t);
+
 
 void    raidstart(RF_Raid_t * raidPtr);
 int     rf_DispatchKernelIO(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req);
diff -r 721f862a9c44 -r 1aad680ee6f4 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Fri Jul 29 19:19:14 2011 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Fri Jul 29 19:55:50 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.291 2011/05/11 18:13:12 mrg Exp $ */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.292 2011/07/29 19:55:50 oster 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.291 2011/05/11 18:13:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.292 2011/07/29 19:55:50 oster Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -297,7 +297,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 *, uint64_t);
+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);
@@ -3132,7 +3132,7 @@
 }
 
 
-static int
+int
 rf_reasonable_label(RF_ComponentLabel_t *clabel, uint64_t numsecs)
 {
 
@@ -3157,7 +3157,8 @@
                 * label looks reasonable enough...
                 * let's make sure it has no old garbage.
                 */
-               rf_fix_old_label_size(clabel, numsecs);
+               if (numsecs)
+                       rf_fix_old_label_size(clabel, numsecs);
                return(1);
        }
        return(0);



Home | Main Index | Thread Index | Old Index