lkml.org 
[lkml]   [1997]   [Dec]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectPatch to boot with md device
HI,

As I wanted to boot from md0 with md0 set as a striped device over my
two IDE controllers, I wrote this patch. It works great. File system
performance increases to nearly the double speed. You can install your
md device with the following kernel command line:

md=<md device no.>,<raid level>,<chunk size factor>,<fault
level>,dev0,dev1,...,devn

md device no. = the number of the md device ... 0 means md0, 1 md1, ...
up to currently 4.

raid level = -1 linear mode
0 striped mode
1 raid-1
5 raid-5
other modes are currently unsupported.

chunk size factor = (raid-0 and raid-1 only)
Set the chunk size as PAGE_SIZE << n.

fault level = (raid-1 only)
Set the maximum fault number as n.

dev0-devn: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1

my loadlin line looks like this:
e:\loadlin\loadlin e:\zimage root=/dev/md0
md=0,0,4,0,/dev/hdb2,/dev/hdc3 ro

BUT .. BE CAREFUL ... BACKUP IMPORTANT FILES ....

This patch applies over version 2.1.75 and 2.1.76 without any problems.

May your performance increase,
Harald

--
mailto:HarryH@Royal.Net http://hot.spotline.de
http://home.pages.de/~saturn
___________________________________________________________________________
Computers are like air conditioner. Both stop working, if you open
windows.--- linux-2.1/CREDITS Mon Dec 29 16:54:12 1997
+++ linux/CREDITS Sun Dec 28 22:54:34 1997
@@ -714,6 +714,16 @@
S: Wantage, New Jersey 07461
S: USA

+N: Harald Hoyer
+E: HarryH@Royal.Net
+W: http://hot.spotline.de/
+W: http://home.pages.de/~saturn
+D: ip_masq_quake
+D: md boot support
+S: Alleenstrasse 27
+S: D-71679 Asperg
+S: Germany
+
N: Miguel de Icaza Amozurrutia
E: miguel@nuclecu.unam.mx
D: Linux/SPARC team, Midnight Commander maintainer
--- linux-2.1/drivers/block/md.c Mon Dec 29 16:53:50 1997
+++ linux/drivers/block/md.c Sun Dec 28 23:10:55 1997
@@ -8,6 +7,7 @@
A lot of inspiration came from hd.c ...

kerneld support by Boris Tobotras <boris@xtalk.msk.su>
+ boot support by Harald Hoyer <HarryH@Royal.Net>

RAID-1/RAID-5 extensions by:
Ingo Molnar, Miguel de Icaza, Gadi Oxman
@@ -59,6 +59,8 @@
#include <asm/bitops.h>
#include <asm/atomic.h>

+extern dev_t name_to_dev_t(char *line) __init;
+
static struct hd_struct md_hd_struct[MAX_MD_DEV];
static int md_blocksizes[MAX_MD_DEV];
int md_maxreadahead[MAX_MD_DEV];
@@ -1054,7 +1056,7 @@
*/
curr_bsize = blksize_size[major][minor];
if (curr_bsize != blocksize) {
-diff_blocksize:
+ diff_blocksize:
if (curr_bsize > blocksize)
/*
* this is safe, rounds downwards.
@@ -1162,6 +1164,82 @@

}

+struct {
+ int set;
+ int ints[100];
+ char str[100];
+} md_setup_args __initdata = {
+ 0,{0},{0}
+};
+
+/* called from init/main.c */
+__initfunc(void md_setup(char *str,int *ints))
+{
+ 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;
+}
+
+__initfunc(void do_md_setup(char *str,int *ints))
+{
+ int minor, pers, factor, fault;
+ dev_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) {
+ printk ("md: Minor device number too high.\n");
+ return;
+ }
+
+ switch(ints[i++]) { /* Raidlevel */
+ case -1:
+ pers = LINEAR;
+ printk ("md: Setting up md%d as linear device.\n",minor);
+ break;
+ case 0:
+ pers = STRIPED;
+ printk ("md: Setting up md%d as a striped device.\n",minor);
+ break;
+ 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 raid level %d.\n", ints[--i]);
+ return;
+ }
+
+ factor=ints[i++]; /* Chunksize */
+ fault =ints[i++]; /* Faultlevel */
+
+ pers=pers | factor | (fault << FAULT_SHIFT);
+
+ while( str && (dev = name_to_dev_t(str))) {
+ do_md_add (minor, dev);
+ if(str = strchr (str, ','))
+ str++;
+ }
+
+ do_md_run (minor, pers);
+ printk ("md: Loading md%d.\n",minor);
+}
+
void linear_init (void);
void raid0_init (void);
void raid1_init (void);
@@ -1215,6 +1293,12 @@
#ifdef CONFIG_MD_RAID5
raid5_init ();
#endif
-
return (0);
}
+
+__initfunc(void md_setup_drive(void))
+{
+ if(md_setup_args.set)
+ do_md_setup(md_setup_args.str, md_setup_args.ints);
+}
+
--- linux-2.1/drivers/block/genhd.c Mon Dec 29 16:53:07 1997
+++ linux/drivers/block/genhd.c Fri Dec 26 14:17:59 1997
@@ -1040,6 +1040,9 @@
#ifdef CONFIG_PARPORT
extern int parport_init(void);
#endif
+#ifdef CONFIG_BLK_DEV_MD
+ extern void md_setup_drive(void) __init;
+#endif
struct gendisk *p;
int nr=0;

@@ -1069,5 +1072,8 @@
else
#endif
rd_load();
+#endif
+#ifdef CONFIG_BLK_DEV_MD
+ md_setup_drive();
#endif
}
--- linux-2.1/init/main.c Mon Dec 29 16:53:07 1997
+++ linux/init/main.c Fri Dec 26 14:16:18 1997
@@ -272,6 +272,10 @@
extern void ipc_init(void);
#endif

+#ifdef CONFIG_BLK_DEV_MD
+extern void md_setup(char *str,int *ints) __init;
+#endif
+
#ifdef __sparc__
extern int serial_console;
#endif
@@ -368,6 +372,9 @@
#ifdef CONFIG_BLK_DEV_FD
{ "fd", 0x0200 },
#endif
+#ifdef CONFIG_BLK_DEV_MD
+ { "md", 0x0900 },
+#endif
#ifdef CONFIG_BLK_DEV_XD
{ "xda", 0x0d00 },
{ "xdb", 0x0d40 },
@@ -413,7 +420,7 @@
{ NULL, 0 }
};

-__initfunc(static void root_dev_setup(char *line, int *num))
+__initfunc(dev_t name_to_dev_t(char *line))
{
int base = 0;
if (strncmp(line,"/dev/",5) == 0) {
@@ -429,7 +436,12 @@
dev++;
} while (dev->name);
}
- ROOT_DEV = to_kdev_t(base + simple_strtoul(line,NULL,base?10:16));
+ return to_kdev_t(base + simple_strtoul(line,NULL,base?10:16));
+}
+
+__initfunc(static void root_dev_setup(char *line, int *num))
+{
+ ROOT_DEV = name_to_dev_t(line);
}

/*
@@ -711,6 +723,9 @@
#endif
#ifdef CONFIG_FTAPE
{ "ftape=", ftape_setup},
+#endif
+#ifdef CONFIG_BLK_DEV_MD
+ { "md=", md_setup},
#endif
{ 0, 0 }
};
\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.043 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site