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 the ability to autoconfigure raid comp...



details:   https://anonhg.NetBSD.org/src/rev/d215ff3ee801
branches:  trunk
changeset: 777358:d215ff3ee801
user:      buhrow <buhrow%NetBSD.org@localhost>
date:      Thu Feb 16 06:52:03 2012 +0000

description:
Add the ability to autoconfigure raid components on raw disks.
This change causes components on raw disks, as opposed to components inside
partitions or wedges, to be autoconfigured if the raid set is configured
for autoconfiguration.

Approved by oster@ and mrg@ for submission after the NetBSD-6 tag.  I've
been running these changes in production at my day job for over a year
without a problem.

See http://mail-index.NetBSD.org/tech-kern/2010/11/09/msg009167.html
for the original discussion of this patch and for a version of this patch
that works with NetBSD-5.x systems.

diffstat:

 sys/dev/raidframe/rf_netbsdkintf.c |  37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diffs (86 lines):

diff -r d694c011d48a -r d215ff3ee801 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Thu Feb 16 04:52:47 2012 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Thu Feb 16 06:52:03 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.295 2011/11/05 16:40:35 erh Exp $ */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.296 2012/02/16 06:52:03 buhrow Exp $      */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.295 2011/11/05 16:40:35 erh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.296 2012/02/16 06:52:03 buhrow Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2992,7 +2992,7 @@
        device_t dv;
        deviter_t di;
        dev_t dev;
-       int bmajor, bminor, wedge;
+       int bmajor, bminor, wedge, rf_part_found;
        int error;
        int i;
        RF_AutoConfig_t *ac_list;
@@ -3039,6 +3039,8 @@
                /* need to find the device_name_to_block_device_major stuff */
                bmajor = devsw_name2blk(device_xname(dv), NULL, 0);
 
+               rf_part_found = 0; /*No raid partition as yet*/
+
                /* get a vnode for the raw partition of this disk */
 
                wedge = device_is_a(dv, "dk");
@@ -3084,6 +3086,7 @@
                                
                        ac_list = rf_get_component(ac_list, dev, vp,
                            device_xname(dv), dkw.dkw_size, numsecs, secsize);
+                       rf_part_found = 1; /*There is a raid component on this disk*/
                        continue;
                }
 
@@ -3108,6 +3111,7 @@
                if (error)
                        continue;
 
+               rf_part_found = 0; /*No raid partitions yet*/
                for (i = 0; i < label.d_npartitions; i++) {
                        char cname[sizeof(ac_list->devname)];
 
@@ -3129,6 +3133,33 @@
                            device_xname(dv), 'a' + i);
                        ac_list = rf_get_component(ac_list, dev, vp, cname,
                                label.d_partitions[i].p_size, numsecs, secsize);
+                               rf_part_found = 1; /*There is at least one raid partition on this disk*/
+               }
+
+               /*
+                *If there is no raid component on this disk, either in a
+                *disklabel or inside a wedge, check the raw partition as well,
+                *as it is possible to configure raid components on raw disk
+                *devices.
+                */
+
+               if (!rf_part_found) {
+                       char cname[sizeof(ac_list->devname)];
+
+                       dev = MAKEDISKDEV(bmajor, device_unit(dv), RAW_PART);
+                       if (bdevvp(dev, &vp))
+                               panic("RAID can't alloc vnode");
+
+                       error = VOP_OPEN(vp, FREAD, NOCRED);
+                       if (error) {
+                               /* Whatever... */
+                               vput(vp);
+                               continue;
+                       }
+                       snprintf(cname, sizeof(cname), "%s%c",
+                           device_xname(dv), 'a' + RAW_PART);
+                       ac_list = rf_get_component(ac_list, dev, vp, cname,
+                               label.d_partitions[RAW_PART].p_size, numsecs, secsize);
                }
        }
        deviter_release(&di);



Home | Main Index | Thread Index | Old Index