Module Name:    src
Committed By:   riz
Date:           Wed Mar 21 16:14:58 UTC 2012

Modified Files:
        src/sys/dev/raidframe [netbsd-6]: rf_netbsdkintf.c

Log Message:
Pull up following revision(s) (requested by buhrow in ticket #133):
        sys/dev/raidframe/rf_netbsdkintf.c: revision 1.296
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.


To generate a diff of this commit:
cvs rdiff -u -r1.295 -r1.295.6.1 src/sys/dev/raidframe/rf_netbsdkintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.295 src/sys/dev/raidframe/rf_netbsdkintf.c:1.295.6.1
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.295	Sat Nov  5 16:40:35 2011
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Wed Mar 21 16:14:57 2012
@@ -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.295.6.1 2012/03/21 16:14:57 riz 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.295.6.1 2012/03/21 16:14:57 riz Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2992,7 +2992,7 @@ rf_find_raid_components(void)
 	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 @@ rf_find_raid_components(void)
 		/* 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 @@ rf_find_raid_components(void)
 				
 			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 @@ rf_find_raid_components(void)
 		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 @@ rf_find_raid_components(void)
 			    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);

Reply via email to