lkml.org 
[lkml]   [1999]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Fix 2.3.x MD boot support
Gee, am I the only person whose root FS lies on striped media?  :-)
For recent vintage 2.3 kernels, specifying "md=..." on the command line is a
no-op;
drivers/block/md.c has not been updated since 2.2 days, where two args instead
of one
were passed to the various foo_setup() functions. Since none of the usual
kernel devos
have submitted a patch, here's my contribution...

In addition to the bare-minimum fix to make CONFIG_MD_BOOT work as it did
in 2.2, I have also "fixed" the misfeature which prevents you from
initialising more
than one MD device on the command line. (Because the command line parsing
occurs prior to initialisation of the physical disk drivers, the parameters
must be
saved until they can be used. The 2.2 and current 2.3 versions of md.c use a
single
array in `struct md_setup_args' for the purpose, overwritten as each md= line
is
parsed. I updated the struct to keep one set of parameters for each of the
MAX_MD_DEV possible devices.) Augmented the printk's a wee bit.

The patch (attached) is against vanilla 2.3.29. Booted it a few times to test
it,
with various sensible and non-sensible parameters, and am writing this on it.
Regards,
Kris K.

--- linux/drivers/block/md.c.vanilla Thu Nov 4 21:40:43 1999
+++ linux/drivers/block/md.c Sat Nov 27 19:44:53 1999
@@ -1176,98 +1176,85 @@

#ifdef CONFIG_MD_BOOT
struct {
- int set;
- int ints[100];
- char str[100];
+ unsigned long set;
+ int pers[MAX_MD_DEV];
+ kdev_t devices[MAX_MD_DEV][MAX_REAL];
} md_setup_args __initdata = {
- 0,{0},{0}
+ 0,{0},{{0}}
};

-/* called from init/main.c */
-void __init md_setup(char *str,int *ints)
+/*
+ * Parse the command-line parameters given our kernel, but do not
+ * actually try to invoke the MD device now; that is handled by
+ * md_setup_drive after the low-level disk drivers have initialised.
+ *
+ * 27/11/1999: Fixed to work correctly with the 2.3 kernel (which
+ * assigns the task of parsing integer arguments to the
+ * invoked program now). Added ability to initialise all
+ * the MD devices (by specifying multiple "md=" lines)
+ * instead of just one. -- KTK
+ */
+int __init md_setup(char *str)
{
- int i;
- for(i=0;i<=ints[0];i++) {
- md_setup_args.ints[i] = ints[i];
- strcpy(md_setup_args.str, str);
-/* printk ("md: ints[%d]=%d.\n", i, ints[i]);*/
- }
- md_setup_args.set=1;
- return;
-}
-
-void __init do_md_setup(char *str,int *ints)
-{
- int minor, pers, factor, fault;
- kdev_t dev;
- int i=1;
-
- if(ints[0] < 4) {
- printk ("md: Too few Arguments (%d).\n", ints[0]);
- return;
- }
-
- minor=ints[i++];
-
- if (minor >= MAX_MD_DEV) {
+ int minor, level, factor, fault, i;
+ kdev_t device;
+ char *devnames, *pername;
+
+ if(get_option(&str, &minor) != 2 || /* MD Number */
+ get_option(&str, &level) != 2 || /* RAID Personality */
+ get_option(&str, &factor) != 2 || /* Chunk Size */
+ get_option(&str, &fault) != 2) {
+ printk("md: Too few arguments supplied to md=.\n");
+ return 0;
+ } else if (minor >= MAX_MD_DEV) {
printk ("md: Minor device number too high.\n");
- return;
+ return 0;
+ } else if (md_setup_args.set & (1 << minor)) {
+ printk ("md: Warning - md=%d,... has been specified twice;\n"
+ " will discard the first definition.\n", minor);
}
-
- pers = 0;
-
- switch(ints[i++]) { /* Raidlevel */
- case -1:
+ switch(level) {
#ifdef CONFIG_MD_LINEAR
- pers = LINEAR;
- printk ("md: Setting up md%d as linear device.\n",minor);
-#else
- printk ("md: Linear mode not configured."
- "Recompile the kernel with linear mode enabled!\n");
-#endif
+ case -1:
+ level = LINEAR;
+ pername = "linear";
break;
- case 0:
- pers = STRIPED;
-#ifdef CONFIG_MD_STRIPED
- printk ("md: Setting up md%d as a striped device.\n",minor);
-#else
- printk ("md: Striped mode not configured."
- "Recompile the kernel with striped mode enabled!\n");
#endif
+#ifdef CONFIG_MD_STRIPED
+ case 0:
+ level = STRIPED;
+ pername = "striped";
break;
-/* not supported yet
- case 1:
- pers = RAID1;
- printk ("md: Setting up md%d as a raid1 device.\n",minor);
- break;
- case 5:
- pers = RAID5;
- printk ("md: Setting up md%d as a raid5 device.\n",minor);
- break;
-*/
- default:
- printk ("md: Unknown or not supported raid level %d.\n", ints[--i]);
- return;
+#endif
+ default:
+ printk ("md: The kernel has not been configured for raid%d"
+ " support!\n", level);
+ return 0;
}
-
- if(pers) {
-
- factor=ints[i++]; /* Chunksize */
- fault =ints[i++]; /* Faultlevel */
-
- pers=pers | factor | (fault << FAULT_SHIFT);
-
- while( str && (dev = name_to_kdev_t(str))) {
- do_md_add (minor, dev);
- if((str = strchr (str, ',')) != NULL)
- str++;
- }
-
- do_md_run (minor, pers);
- printk ("md: Loading md%d.\n",minor);
+ devnames = str;
+ for (i = 0; str; i++) {
+ if ((device = name_to_kdev_t(str))) {
+ md_setup_args.devices[minor][i] = device;
+ } else {
+ printk ("md: Unknown device name, %s.\n", str);
+ return 0;
+ }
+ if ((str = strchr(str, ',')) != NULL)
+ str++;
}
-
+ if (!i) {
+ printk ("md: No devices specified for md%d?\n", minor);
+ return 0;
+ }
+
+ printk ("md: Will configure md%d (%s) from %s, below.\n",
+ minor, pername, devnames);
+ md_setup_args.devices[minor][i] = (kdev_t) 0;
+ md_setup_args.pers[minor] = level | factor | (fault << FAULT_SHIFT);
+ md_setup_args.set |= (1 << minor);
+ return 0;
}
+
#endif

void linear_init (void);
@@ -1318,7 +1305,18 @@
#ifdef CONFIG_MD_BOOT
void __init md_setup_drive(void)
{
- if(md_setup_args.set)
- do_md_setup(md_setup_args.str, md_setup_args.ints);
+ int minor, i;
+ kdev_t dev;
+
+ for (minor = 0; minor < MAX_MD_DEV; minor++) {
+ if ((md_setup_args.set & (1 << minor)) == 0)
+ continue;
+ printk("md: Loading md%d.\n", minor);
+ for (i = 0; (dev = md_setup_args.devices[minor][i]); i++)
+ do_md_add (minor, dev);
+ do_md_run (minor, md_setup_args.pers[minor]);
+ }
}
+
+__setup("md=", md_setup);
#endif
\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.031 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site