patch-2.4.2 linux/drivers/md/md.c

Next file: linux/drivers/md/raid1.c
Previous file: linux/drivers/md/linear.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.1/linux/drivers/md/md.c linux/drivers/md/md.c
@@ -61,6 +61,10 @@
 # define dprintk(x...) do { } while(0)
 #endif
 
+#ifndef MODULE
+static void autostart_arrays (void);
+#endif
+
 static mdk_personality_t *pers[MAX_PERSONALITY];
 
 /*
@@ -2030,70 +2034,6 @@
 #undef AUTOADDING
 #undef AUTORUNNING
 
-struct {
-	int set;
-	int noautodetect;
-} raid_setup_args md__initdata;
-
-void md_setup_drive (void) md__init;
-
-/*
- * Searches all registered partitions for autorun RAID arrays
- * at boot time.
- */
-static int detected_devices[128] md__initdata;
-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 (void)
-{
-	mdk_rdev_t *rdev;
-	int i;
-
-	printk(KERN_INFO "autodetecting RAID arrays\n");
-
-	for (i=0; i<dev_cnt; i++) {
-		kdev_t dev = detected_devices[i];
-
-		if (md_import_device(dev,1)) {
-			printk(KERN_ALERT "could not import %s!\n",
-			       partition_name(dev));
-			continue;
-		}
-		/*
-		 * Sanity checks:
-		 */
-		rdev = find_rdev_all(dev);
-		if (!rdev) {
-			MD_BUG();
-			continue;
-		}
-		if (rdev->faulty) {
-			MD_BUG();
-			continue;
-		}
-		md_list_add(&rdev->pending, &pending_raid_disks);
-	}
-
-	autorun_devices(-1);
-}
-
-int md__init md_run_setup(void)
-{
-	if (raid_setup_args.noautodetect)
-		printk(KERN_INFO "skipping autodetection of RAID arrays\n");
-	else
-		autostart_arrays();
-	dev_cnt = -1; /* make sure further calls to md_autodetect_dev are ignored */
-	md_setup_drive();
-	return 0;
-}
 
 static int get_version (void * arg)
 {
@@ -2555,10 +2495,12 @@
 			md_print_devices();
 			goto done_unlock;
 
+#ifndef MODULE
 		case RAID_AUTORUN:
 			err = 0;
 			autostart_arrays();
 			goto done;
+#endif
 
 		case BLKGETSIZE:   /* Return device size */
 			if (!arg) {
@@ -2590,7 +2532,7 @@
 			err = md_put_user (read_ahead[
 				MAJOR(dev)], (long *) arg);
 			goto done;
-		default:
+		default:;
 	}
 
 	/*
@@ -2609,7 +2551,7 @@
 				err = -EEXIST;
 				goto abort;
 			}
-		default:
+		default:;
 	}
 	switch (cmd)
 	{
@@ -2662,7 +2604,7 @@
 			}
 			goto done;
 
-		default:
+		default:;
 	}
 
 	/*
@@ -3556,30 +3498,7 @@
 	NULL,
 	0
 };
-#ifndef MODULE
-static int md__init raid_setup(char *str)
-{
-	int len, pos;
-
-	len = strlen(str) + 1;
-	pos = 0;
-
-	while (pos < len) {
-		char *comma = strchr(str+pos, ',');
-		int wlen;
-		if (comma)
-			wlen = (comma-str)-pos;
-		else	wlen = (len-1)-pos;
 
-		if (strncmp(str, "noautodetect", wlen) == 0)
-			raid_setup_args.noautodetect = 1;
-		pos += wlen+1;
-	}
-	raid_setup_args.set = 1;
-	return 1;
-}
-__setup("raid=", raid_setup);
-#endif
 static void md_geninit (void)
 {
 	int i;
@@ -3641,6 +3560,70 @@
 	return (0);
 }
 
+
+#ifndef MODULE
+
+/*
+ * When md (and any require personalities) are compiled into the kernel
+ * (not a module), arrays can be assembles are boot time using with AUTODETECT
+ * where specially marked partitions are registered with md_autodetect_dev(),
+ * and with MD_BOOT where devices to be collected are given on the boot line
+ * with md=.....
+ * The code for that is here.
+ */
+
+struct {
+	int set;
+	int noautodetect;
+} raid_setup_args md__initdata;
+
+/*
+ * Searches all registered partitions for autorun RAID arrays
+ * at boot time.
+ */
+static int detected_devices[128] md__initdata;
+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 (void)
+{
+	mdk_rdev_t *rdev;
+	int i;
+
+	printk(KERN_INFO "autodetecting RAID arrays\n");
+
+	for (i=0; i<dev_cnt; i++) {
+		kdev_t dev = detected_devices[i];
+
+		if (md_import_device(dev,1)) {
+			printk(KERN_ALERT "could not import %s!\n",
+			       partition_name(dev));
+			continue;
+		}
+		/*
+		 * Sanity checks:
+		 */
+		rdev = find_rdev_all(dev);
+		if (!rdev) {
+			MD_BUG();
+			continue;
+		}
+		if (rdev->faulty) {
+			MD_BUG();
+			continue;
+		}
+		md_list_add(&rdev->pending, &pending_raid_disks);
+	}
+
+	autorun_devices(-1);
+}
+
 static struct {
 	char device_set [MAX_MD_DEVS];
 	int pers[MAX_MD_DEVS];
@@ -3665,6 +3648,7 @@
  *             elements in device-list are read by name_to_kdev_t so can be
  *             a hex number or something like /dev/hda1 /dev/sdb
  */
+#ifndef MODULE
 extern kdev_t name_to_kdev_t(char *line) md__init;
 static int md__init md_setup(char *str)
 {
@@ -3740,6 +3724,7 @@
 	md_setup_args.device_set[minor] = 1;
 	return 1;
 }
+#endif /* !MODULE */
 
 void md__init md_setup_drive(void)
 {
@@ -3807,9 +3792,47 @@
 	}
 }
 
+static int md__init raid_setup(char *str)
+{
+	int len, pos;
+
+	len = strlen(str) + 1;
+	pos = 0;
+
+	while (pos < len) {
+		char *comma = strchr(str+pos, ',');
+		int wlen;
+		if (comma)
+			wlen = (comma-str)-pos;
+		else	wlen = (len-1)-pos;
+
+		if (strncmp(str, "noautodetect", wlen) == 0)
+			raid_setup_args.noautodetect = 1;
+		pos += wlen+1;
+	}
+	raid_setup_args.set = 1;
+	return 1;
+}
+
+int md__init md_run_setup(void)
+{
+	if (raid_setup_args.noautodetect)
+		printk(KERN_INFO "skipping autodetection of RAID arrays\n");
+	else
+		autostart_arrays();
+	dev_cnt = -1; /* make sure further calls to md_autodetect_dev are ignored */
+	md_setup_drive();
+	return 0;
+}
+
+__setup("raid=", raid_setup);
 __setup("md=", md_setup);
 
-#ifdef MODULE
+__initcall(md_init);
+__initcall(md_run_setup);
+
+#else /* It is a MODULE */
+
 int init_module (void)
 {
 	return md_init();
@@ -3857,9 +3880,6 @@
 
 }
 #endif
-
-__initcall(md_init);
-__initcall(md_run_setup);
 
 MD_EXPORT_SYMBOL(md_size);
 MD_EXPORT_SYMBOL(register_md_personality);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)