Subject: Re: Boot device confusion
To: Christos Zoulas <christos@tac.gw.com>
From: Allen Briggs <briggs@netbsd.org>
List: tech-kern
Date: 06/20/2005 14:19:51
On Mon, Jun 20, 2005 at 07:55:25PM +0300, Christos Zoulas wrote:
> I think marking raid component devices so that they do not participate
> as standalone devices is the easiest solution.

It's definitely that.  The following patch does it for me.  If
no one raises issues with it, I'll commit it.

Comments?

-allen

Index: sys/device.h
===================================================================
RCS file: /cvsroot/src/sys/sys/device.h,v
retrieving revision 1.74
diff -p -u -r1.74 device.h
--- sys/device.h	19 Jun 2005 23:09:50 -0000	1.74
+++ sys/device.h	20 Jun 2005 18:18:03 -0000
@@ -118,6 +118,8 @@ struct device {
 
 /* dv_flags */
 #define	DVF_ACTIVE	0x0001		/* device is activated */
+#define	DVF_MEMBER	0x0002		/* device is used by another device */
+				/* as in a disk that's a member of a RAID */
 
 TAILQ_HEAD(devicelist, device);
 
Index: arch/x86/x86/x86_autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/x86_autoconf.c,v
retrieving revision 1.4
diff -p -u -r1.4 x86_autoconf.c
--- arch/x86/x86/x86_autoconf.c	29 May 2005 21:36:40 -0000	1.4
+++ arch/x86/x86/x86_autoconf.c	20 Jun 2005 18:18:04 -0000
@@ -397,7 +397,12 @@ findroot(void)
 		 */
 		for (dv = TAILQ_FIRST(&alldevs); dv != NULL;
 		     dv = TAILQ_NEXT(dv, dv_list)) {
-			if (dv->dv_class != DV_DISK)
+			/*
+			 * If the disk is marked as a member of an array,
+			 * do not consider it.
+			 */
+			if (dv->dv_class != DV_DISK ||
+			    (dv->dv_flags & DVF_MEMBER) != 0)
 				continue;
 
 			if (is_valid_disk(dv)) {
@@ -437,7 +442,13 @@ findroot(void)
 		 */
 		for (dv = TAILQ_FIRST(&alldevs); dv != NULL;
 		     dv = TAILQ_NEXT(dv, dv_list)) {
-			if (dv->dv_class != DV_DISK)
+
+			/*
+			 * If the disk is marked as a member of an array,
+			 * do not consider it.
+			 */
+			if (dv->dv_class != DV_DISK ||
+			    (dv->dv_flags & DVF_MEMBER) != 0)
 				continue;
 
 			if (strcmp(dv->dv_cfdata->cf_name, "fd") == 0) {
Index: dev/ata/ld_ataraid.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/ld_ataraid.c,v
retrieving revision 1.13
diff -p -u -r1.13 ld_ataraid.c
--- dev/ata/ld_ataraid.c	28 Oct 2004 07:07:39 -0000	1.13
+++ dev/ata/ld_ataraid.c	20 Jun 2005 18:18:04 -0000
@@ -217,6 +217,11 @@ ld_ataraid_attach(struct device *parent,
 
 		VOP_UNLOCK(vp, 0);
 		sc->sc_vnodes[i] = vp;
+
+		/*
+		 * Mark the component disks as members.
+		 */
+		adi->adi_dev->dv_flags |= DVF_MEMBER;
 	}
 	if (i == aai->aai_ndisks) {
 		ld->sc_flags = LDF_ENABLED;

-- 
                  Use NetBSD!  http://www.NetBSD.org/