MD Boot patch V1.2 with config support

Harald Hoyer (HarryH@Royal.Net)
Wed, 14 Jan 1998 17:13:38 +0100


This is a multi-part message in MIME format.
--------------D6E2EECEB6EECADEC3ABEF07
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

HI,

to boot with the md device in linear and striped mode, you may use this
patch.
It now has config-features and will hoply apply to linux-2.1.79.

- checked the config ifdefs, so that other users don't have problems
installing
this patch

- added Documentation/md.txt

- added entry in Documentation/Configure.help for CONFIG_MD_BOOT

Harald Hoyer

-- 
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.
--------------D6E2EECEB6EECADEC3ABEF07
Content-Type: text/plain; charset=us-ascii; name="patch-2.1.79.mdboot"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="patch-2.1.79.mdboot"

Index: linux/CREDITS diff -u linux/CREDITS:1.1.1.27 linux/CREDITS:1.1.1.27.4.1 --- linux/CREDITS:1.1.1.27 Wed Jan 7 11:17:14 1998 +++ linux/CREDITS Tue Jan 13 14:40:57 1998 @@ -728,6 +728,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 Index: linux/Documentation/Configure.help diff -u linux/Documentation/Configure.help:1.1.1.28 linux/Documentation/Configure.help:1.1.1.28.2.1 --- linux/Documentation/Configure.help:1.1.1.28 Tue Jan 13 12:09:01 1998 +++ linux/Documentation/Configure.help Tue Jan 13 14:41:04 1998 @@ -647,6 +647,11 @@ want to compile it as a module, say M here and read Documentation/modules.txt. If unsure, say Y. +Boot support (linear, striped) +CONFIG_MD_BOOT + To boot with an initial linear or striped md device you have to + select this. For lilo and loadlin options see Documentation/md.txt. + Support for Deskstation RPC44 CONFIG_DESKSTATION_RPC44 This is a machine with a R4400 100 MHz CPU. To compile a Linux Index: linux/Documentation/md.txt diff -u /dev/null linux/Documentation/md.txt:1.1.4.1 --- /dev/null Tue Jan 13 14:42:13 1998 +++ linux/Documentation/md.txt Tue Jan 13 14:41:06 1998 @@ -0,0 +1,37 @@ +Tools that manage md devices can be found at sweet-smoke.ufr-info-p7.ibp.fr +in public/Linux/md035.tar.gz. + + Marc ZYNGIER <zyngier@ufr-info-p7.ibp.fr> + +-- + +You can boot (if you selected boot support in the configuration) with 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, + 2 md2, + 3 md3, + 4 md4 + +raid level = -1 linear mode + 0 striped mode + 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. + Currently unsupported due to lack of boot support for raid1. + +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 + + Harald Hoyer <HarryH@Royal.Net> Index: linux/drivers/block/Config.in diff -u linux/drivers/block/Config.in:1.1.1.9 linux/drivers/block/Config.in:1.1.1.9.4.1 --- linux/drivers/block/Config.in:1.1.1.9 Wed Jan 7 11:19:01 1998 +++ linux/drivers/block/Config.in Tue Jan 13 14:41:14 1998 @@ -65,6 +65,9 @@ tristate ' RAID-1 (mirroring) mode' CONFIG_MD_MIRRORING tristate ' RAID-4/RAID-5 mode' CONFIG_MD_RAID5 fi +if [ "$CONFIG_MD_LINEAR" = "y" -o "$CONFIG_MD_STRIPED" = "y" ]; then + bool ' Boot support (linear, striped)' CONFIG_MD_BOOT +fi tristate 'RAM disk support' CONFIG_BLK_DEV_RAM if [ "$CONFIG_BLK_DEV_RAM" = "y" ]; then bool ' Initial RAM disk (initrd) support' CONFIG_BLK_DEV_INITRD Index: linux/drivers/block/genhd.c diff -u linux/drivers/block/genhd.c:1.1.1.6 linux/drivers/block/genhd.c:1.1.1.6.4.1 --- linux/drivers/block/genhd.c:1.1.1.6 Wed Jan 7 11:19:03 1998 +++ linux/drivers/block/genhd.c Tue Jan 13 14:41:14 1998 @@ -1092,6 +1092,9 @@ #ifdef CONFIG_PARPORT extern int parport_init(void); #endif +#ifdef CONFIG_MD_BOOT + extern void md_setup_drive(void) __init; +#endif struct gendisk *p; int nr=0; @@ -1121,5 +1124,8 @@ else #endif rd_load(); +#endif +#ifdef CONFIG_MD_BOOT + md_setup_drive(); #endif } Index: linux/drivers/block/md.c diff -u linux/drivers/block/md.c:1.1.1.8 linux/drivers/block/md.c:1.1.1.8.4.1 --- linux/drivers/block/md.c:1.1.1.8 Wed Jan 7 11:19:07 1998 +++ linux/drivers/block/md.c Tue Jan 13 14:41:15 1998 @@ -8,6 +8,7 @@ A lot of inspiration came from hd.c ... kerneld support by Boris Tobotras <boris@xtalk.msk.su> + boot support for linear and striped mode by Harald Hoyer <HarryH@Royal.Net> RAID-1/RAID-5 extensions by: Ingo Molnar, Miguel de Icaza, Gadi Oxman @@ -59,6 +60,10 @@ #include <asm/bitops.h> #include <asm/atomic.h> +#ifdef CONFIG_MD_BOOT +extern dev_t name_to_dev_t(char *line) __init; +#endif + 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 +1059,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 +1167,102 @@ } +#ifdef CONFIG_MD_BOOT +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; + } + + pers = 0; + + switch(ints[i++]) { /* Raidlevel */ + case -1: +#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",minor); +#endif + 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",minor); +#endif + 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; + } + + if(pers) { + + 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); + } + +} +#endif + void linear_init (void); void raid0_init (void); void raid1_init (void); @@ -1215,6 +1316,13 @@ #ifdef CONFIG_MD_RAID5 raid5_init (); #endif - return (0); } + +#ifdef CONFIG_MD_BOOT +__initfunc(void md_setup_drive(void)) +{ + if(md_setup_args.set) + do_md_setup(md_setup_args.str, md_setup_args.ints); +} +#endif Index: linux/init/main.c diff -u linux/init/main.c:1.1.1.16 linux/init/main.c:1.1.1.16.4.1 --- linux/init/main.c:1.1.1.16 Wed Jan 7 11:23:55 1998 +++ linux/init/main.c Tue Jan 13 14:41:22 1998 @@ -278,6 +278,10 @@ extern void ipc_init(void); #endif +#ifdef CONFIG_MD_BOOT +extern void md_setup(char *str,int *ints) __init; +#endif + #ifdef __sparc__ extern int serial_console; #endif @@ -374,6 +378,9 @@ #ifdef CONFIG_BLK_DEV_FD { "fd", 0x0200 }, #endif +#ifdef CONFIG_MD_BOOT + { "md", 0x0900 }, +#endif #ifdef CONFIG_BLK_DEV_XD { "xda", 0x0d00 }, { "xdb", 0x0d40 }, @@ -415,7 +422,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) { @@ -431,7 +438,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); } /* @@ -708,6 +720,9 @@ #endif #ifdef CONFIG_FTAPE { "ftape=", ftape_setup}, +#endif +#ifdef CONFIG_MD_BOOT + { "md=", md_setup}, #endif { 0, 0 } };

--------------D6E2EECEB6EECADEC3ABEF07--