--- kernel-source-2.4.21/fs/partitions/efi.c.alt-autodetect-module	2002-11-29 02:53:15 +0300
+++ kernel-source-2.4.21/fs/partitions/efi.c	2003-07-11 17:45:32 +0400
@@ -104,7 +104,7 @@
 #include "check.h"
 #include "efi.h"
 
-#if CONFIG_BLK_DEV_MD
+#if CONFIG_BLK_DEV_MD_AUTODETECT
 extern void md_autodetect_dev(kdev_t dev);
 #endif
 
@@ -735,7 +735,7 @@
 				  1));
 
 		/* If there's this is a RAID volume, tell md */
-#if CONFIG_BLK_DEV_MD
+#if CONFIG_BLK_DEV_MD_AUTODETECT
 		if (!efi_guidcmp(ptes[i].partition_type_guid,
                                  PARTITION_LINUX_RAID_GUID)) {
                         md_autodetect_dev(MKDEV
--- kernel-source-2.4.21/fs/partitions/msdos.c.alt-autodetect-module	2002-11-29 02:53:15 +0300
+++ kernel-source-2.4.21/fs/partitions/msdos.c	2003-07-11 17:45:32 +0400
@@ -42,7 +42,7 @@
 #include "check.h"
 #include "msdos.h"
 
-#if CONFIG_BLK_DEV_MD
+#if CONFIG_BLK_DEV_MD_AUTODETECT
 extern void md_autodetect_dev(kdev_t dev);
 #endif
 
@@ -170,7 +170,7 @@
 			}
 
 			add_gd_partition(hd, *current_minor, next, size);
-#if CONFIG_BLK_DEV_MD
+#if CONFIG_BLK_DEV_MD_AUTODETECT
 			if (SYS_IND(p) == LINUX_RAID_PARTITION) {
 			    md_autodetect_dev(MKDEV(hd->major,*current_minor));
 			}
@@ -587,7 +587,7 @@
 		add_gd_partition(hd, minor,
 				first_sector+START_SECT(p)*sector_size,
 				NR_SECTS(p)*sector_size);
-#if CONFIG_BLK_DEV_MD
+#if CONFIG_BLK_DEV_MD_AUTODETECT
 		if (SYS_IND(p) == LINUX_RAID_PARTITION) {
 			md_autodetect_dev(MKDEV(hd->major,minor));
 		}
--- kernel-source-2.4.21/fs/partitions/sun.c.alt-autodetect-module	2002-11-29 02:53:15 +0300
+++ kernel-source-2.4.21/fs/partitions/sun.c	2003-07-11 17:45:32 +0400
@@ -20,7 +20,7 @@
 #include "check.h"
 #include "sun.h"
 
-#ifdef CONFIG_BLK_DEV_MD
+#ifdef CONFIG_BLK_DEV_MD_AUTODETECT
 extern void md_autodetect_dev(kdev_t dev);
 #endif
 
@@ -93,7 +93,7 @@
 		if (num_sectors) {
 			add_gd_partition(hd, first_part_minor,
 					 st_sector, num_sectors);
-#ifdef CONFIG_BLK_DEV_MD
+#ifdef CONFIG_BLK_DEV_MD_AUTODETECT
 			if (label->infos[i].id == LINUX_RAID_PARTITION)
 				md_autodetect_dev(MKDEV(hd->major,
 							first_part_minor));
--- kernel-source-2.4.21/drivers/md/Config.in.alt-autodetect-module	2001-09-15 01:22:18 +0400
+++ kernel-source-2.4.21/drivers/md/Config.in	2003-07-11 17:45:32 +0400
@@ -7,6 +7,11 @@
 bool 'Multiple devices driver support (RAID and LVM)' CONFIG_MD
 
 dep_tristate ' RAID support' CONFIG_BLK_DEV_MD $CONFIG_MD
+if [ "$CONFIG_BLK_DEV_MD" = "y" ]; then
+   define_bool CONFIG_BLK_DEV_MD_AUTODETECT y
+else
+   dep_mbool '  RAID autodetection support' CONFIG_BLK_DEV_MD_AUTODETECT $CONFIG_BLK_DEV_MD
+fi
 dep_tristate '  Linear (append) mode' CONFIG_MD_LINEAR $CONFIG_BLK_DEV_MD
 dep_tristate '  RAID-0 (striping) mode' CONFIG_MD_RAID0 $CONFIG_BLK_DEV_MD
 dep_tristate '  RAID-1 (mirroring) mode' CONFIG_MD_RAID1 $CONFIG_BLK_DEV_MD
--- kernel-source-2.4.21/drivers/md/Makefile.alt-autodetect-module	2001-11-11 21:09:32 +0300
+++ kernel-source-2.4.21/drivers/md/Makefile	2003-07-11 17:45:32 +0400
@@ -13,6 +13,8 @@
 # themselves, and md.o may use the personalities when it 
 # auto-initialised.
 
+export-objs	+= md-autodetect.o
+obj-$(CONFIG_BLK_DEV_MD_AUTODETECT)	+= md-autodetect.o
 obj-$(CONFIG_MD_LINEAR)		+= linear.o
 obj-$(CONFIG_MD_RAID0)		+= raid0.o
 obj-$(CONFIG_MD_RAID1)		+= raid1.o
--- kernel-source-2.4.21/drivers/md/md-autodetect.c.alt-autodetect-module	2003-07-11 17:45:32 +0400
+++ kernel-source-2.4.21/drivers/md/md-autodetect.c	2003-07-11 17:45:32 +0400
@@ -0,0 +1,54 @@
+/*
+   md-autodetect.c : Multiple Devices driver for Linux
+
+   RAID autodetection support
+
+   Based on md.c:
+   md.c : Multiple Devices driver for Linux
+	  Copyright (C) 1998, 1999, 2000 Ingo Molnar
+
+     completely rewritten, based on the MD driver code from Marc Zyngier
+
+   Changes:
+
+   - RAID-1/RAID-5 extensions by Miguel de Icaza, Gadi Oxman, Ingo Molnar
+   - boot support for linear and striped mode by Harald Hoyer <HarryH@Royal.Net>
+   - kerneld support by Boris Tobotras <boris@xtalk.msk.su>
+   - kmod support by: Cyrus Durgin
+   - RAID0 bugfixes: Mark Anthony Lisher <markal@iname.com>
+   - Devfs support by Richard Gooch <rgooch@atnf.csiro.au>
+
+   - lots of fixes and improvements to the RAID1/RAID5 and generic
+     RAID code (such as request based resynchronization):
+
+     Neil Brown <neilb@cse.unsw.edu.au>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   You should have received a copy of the GNU General Public License
+   (for example /usr/src/linux/COPYING); if not, write to the Free
+   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/kdev_t.h>
+
+kdev_t md_autodetected_devices[128];
+int md_autodetected_devices_count;
+
+void md_autodetect_dev(kdev_t dev)
+{
+	if (md_autodetected_devices_count >= 0
+	    && md_autodetected_devices_count < 127)
+		md_autodetected_devices[md_autodetected_devices_count++] = dev;
+}
+
+#ifdef CONFIG_BLK_DEV_MD_MODULE
+EXPORT_SYMBOL_GPL(md_autodetected_devices);
+EXPORT_SYMBOL_GPL(md_autodetected_devices_count);
+EXPORT_SYMBOL_GPL(md_autodetect_dev);
+#endif /* CONFIG_BLK_DEV_MD_MODULE */
--- kernel-source-2.4.21/drivers/md/md.c.alt-autodetect-module	2003-07-11 17:44:28 +0400
+++ kernel-source-2.4.21/drivers/md/md.c	2003-07-11 17:49:36 +0400
@@ -58,7 +58,7 @@
 # define dprintk(x...) do { } while(0)
 #endif
 
-#ifndef MODULE
+#ifndef CONFIG_BLK_DEV_MD_AUTODETECT
 static void autostart_arrays (kdev_t countdev);
 #endif
 
@@ -697,7 +697,7 @@
 		md_list_del(&rdev->pending);
 		MD_INIT_LIST_HEAD(&rdev->pending);
 	}
-#ifndef MODULE
+#ifdef CONFIG_BLK_DEV_MD_AUTODETECT
 	md_autodetect_dev(rdev->dev);
 #endif
 	rdev->dev = 0;
@@ -2611,7 +2611,7 @@
 			md_print_devices();
 			goto done_unlock;
 
-#ifndef MODULE
+#ifdef CONFIG_BLK_DEV_MD_AUTODETECT
 		case RAID_AUTORUN:
 			err = 0;
 			autostart_arrays(dev);
@@ -3774,19 +3774,17 @@
 	int noautodetect;
 } raid_setup_args md__initdata;
 
+#endif /* MODULE */
+
+#ifdef CONFIG_BLK_DEV_MD_AUTODETECT
+
+extern kdev_t md_autodetected_devices[];
+extern int md_autodetected_devices_count;
+
 /*
  * Searches all registered partitions for autorun RAID arrays
  * at boot time.
  */
-static kdev_t detected_devices[128];
-static int dev_cnt;
-
-void md_autodetect_dev(kdev_t dev)
-{
-	if (dev_cnt >= 0 && dev_cnt < 127)
-		detected_devices[dev_cnt++] = dev;
-}
-
 
 static void autostart_arrays(kdev_t countdev)
 {
@@ -3795,8 +3793,8 @@
 
 	printk(KERN_INFO "md: Autodetecting RAID arrays.\n");
 
-	for (i = 0; i < dev_cnt; i++) {
-		kdev_t dev = detected_devices[i];
+	for (i = 0; i < md_autodetected_devices_count; i++) {
+		kdev_t dev = md_autodetected_devices[i];
 
 		if (md_import_device(dev,1)) {
 			printk(KERN_ALERT "md: could not import %s!\n",
@@ -3817,11 +3815,15 @@
 		}
 		md_list_add(&rdev->pending, &pending_raid_disks);
 	}
-	dev_cnt = 0;
+	md_autodetected_devices_count = 0;
 
 	autorun_devices(countdev);
 }
 
+#endif /* CONFIG_BLK_DEV_MD_AUTODETECT */
+
+#ifndef MODULE
+
 static struct {
 	char device_set [MAX_MD_DEVS];
 	int pers[MAX_MD_DEVS];
--- kernel-source-2.4.21/Documentation/Configure.help.alt-autodetect-module	2003-06-13 18:51:29 +0400
+++ kernel-source-2.4.21/Documentation/Configure.help	2003-07-11 17:45:32 +0400
@@ -1868,6 +1868,14 @@
 
   If unsure, say N.
 
+RAID autodetection support
+CONFIG_BLK_DEV_MD_AUTODETECT
+  If you say Y here, the multiple devices driver module will support
+  autodetection of RAID partitions.  You will still need an additional
+  userspace helper program to run the autodetection at the appropriate
+  time (e.g. after loading all block device drivers and RAID modules
+  from the /linuxrc script in your initrd).
+
 Linear (append) mode
 CONFIG_MD_LINEAR
   If you say Y here, then your multiple devices driver will be able to
