* Raid1 and mdadm
@ 2003-03-29 20:28 Max Booker
2003-03-29 21:54 ` Mads Peter Bach
2003-03-31 11:34 ` Friedrich Lobenstock
0 siblings, 2 replies; 10+ messages in thread
From: Max Booker @ 2003-03-29 20:28 UTC (permalink / raw)
To: Raid
Hello
I am a Linux newbie, using Redhat Linux 7.3 Kernel 2.4.18-17.7.x on an Asus
7V333 with Promise Raid Controller (disabled).
I would like to understand more about Raid in a Linux environment, except
that all the documentation I have read seems not to apply to my case.
I understand that mdadm is better than raidtools, but I still cannot get my
head around the concept of how Linux Raid works.
Neil Brown gave a reply to splee in April, which seems to be relatively
straightforward - however, when I try this method, I get a kernel panic.
My setup is as follows:
GRUB boot loader
hda1 /boot
hda2 /
hda3 swap
hdd1 (intended) mirror partition of /
I can create the (degraded) array on hdd1, mkfs on /dev/md0, mount /dev/md0
as /mnt, copy / to /mnt, and edit /mnt/etc/fstab.
Everything works well up to the point where I reboot, with kernel parameters
(md=0,/dev/hdd1 root=/dev/md0). This is where the kernel panics.
I think that I have not edited fstab properly, or GRUB is getting in the
way, or maybe it is not possible to add hda2 to the array because it already
has a filesystem on it.... How do I get hda2 to be part of the Raid array?
Nothing attempted so far has made any impression on the fact that mdadm
insists that /dev/hda2 is not an md component.
I hope that this is enough info.
Best regards
Max Booker
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Raid1 and mdadm
2003-03-29 20:28 Max Booker
@ 2003-03-29 21:54 ` Mads Peter Bach
2003-03-31 11:34 ` Friedrich Lobenstock
1 sibling, 0 replies; 10+ messages in thread
From: Mads Peter Bach @ 2003-03-29 21:54 UTC (permalink / raw)
To: linux-raid
Max Booker wrote:
> Hello
>
> Everything works well up to the point where I reboot, with kernel parameters
> (md=0,/dev/hdd1 root=/dev/md0). This is where the kernel panics.
>
> I think that I have not edited fstab properly, or GRUB is getting in the
> way, or maybe it is not possible to add hda2 to the array because it already
> has a filesystem on it.... How do I get hda2 to be part of the Raid array?
> Nothing attempted so far has made any impression on the fact that mdadm
> insists that /dev/hda2 is not an md component.
>
> I hope that this is enough info.
It isn't. We'll need to see the panic, and the things leading up to it,
to be able to diagnose what's happening.
Does your kernel have the software raid compiled in, or as modules? If
it's modules, you'll need an initial ramdisk (initrd).
You can add hda2 to the array, after you've successfully booted off the
array.
--
Mads Peter Bach
Systemadministrator, Det Humanistiske Fakultet, Aalborg Universitet
Kroghstræde 3 - 5.111, DK-9220 Aalborg Øst
# whois MPB1-DK@whois.dk-hostmaster.dk
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Raid1 and mdadm
2003-03-29 20:28 Max Booker
2003-03-29 21:54 ` Mads Peter Bach
@ 2003-03-31 11:34 ` Friedrich Lobenstock
1 sibling, 0 replies; 10+ messages in thread
From: Friedrich Lobenstock @ 2003-03-31 11:34 UTC (permalink / raw)
To: Linux RAID Mailing Liste
Max Booker wrote:
>
> GRUB boot loader
>
> hda1 /boot
> hda2 /
> hda3 swap
>
> hdd1 (intended) mirror partition of /
>
> I can create the (degraded) array on hdd1, mkfs on /dev/md0, mount /dev/md0
> as /mnt, copy / to /mnt, and edit /mnt/etc/fstab.
>
> Everything works well up to the point where I reboot, with kernel parameters
> (md=0,/dev/hdd1 root=/dev/md0). This is where the kernel panics.
>
> I think that I have not edited fstab properly, or GRUB is getting in the
> way, or maybe it is not possible to add hda2 to the array because it already
> has a filesystem on it.... How do I get hda2 to be part of the Raid array?
> Nothing attempted so far has made any impression on the fact that mdadm
> insists that /dev/hda2 is not an md component.
>
As far as I know you have to use LILO instead of GRUB to boot
from a root raid. Take care that raid1 is compiled into the kernel.
--
MfG / Regards
Friedrich Lobenstock
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Raid1 and mdadm
@ 2003-03-31 13:33 Sarcar, Shourya C (MED)
0 siblings, 0 replies; 10+ messages in thread
From: Sarcar, Shourya C (MED) @ 2003-03-31 13:33 UTC (permalink / raw)
To: Linux RAID Mailing Liste
Max,
Even if RAID is not compiled into the kernel, you can build an initrd
image (man mkinitrd) and change /etc/lilo.conf to point to the new
initrd image.
This way you will override the pains of a 'proper' kernel compile.
Thanks
Shourya Sarcar
_____________________________________________________
Global Recon Engine, Computed Tomography
Edison Engineering Development Program, GE Medical Systems
3000 N Grandview Blvd., MS W 1200, Waukesha, WI 53188, USA
Tel: 262 312 7405 (O) | *320 7405 (DialComm)
> -----Original Message-----
> From: Friedrich Lobenstock [mailto:fl@fl.priv.at]
> Sent: Monday, March 31, 2003 5:35 AM
> To: Linux RAID Mailing Liste
> Subject: Re: Raid1 and mdadm
>
>
> Max Booker wrote:
> >
> > GRUB boot loader
> >
> > hda1 /boot
> > hda2 /
> > hda3 swap
> >
> > hdd1 (intended) mirror partition of /
> >
> > I can create the (degraded) array on hdd1, mkfs on
> /dev/md0, mount /dev/md0
> > as /mnt, copy / to /mnt, and edit /mnt/etc/fstab.
> >
> > Everything works well up to the point where I reboot, with
> kernel parameters
> > (md=0,/dev/hdd1 root=/dev/md0). This is where the kernel panics.
> >
> > I think that I have not edited fstab properly, or GRUB is
> getting in the
> > way, or maybe it is not possible to add hda2 to the array
> because it already
> > has a filesystem on it.... How do I get hda2 to be part of
> the Raid array?
> > Nothing attempted so far has made any impression on the
> fact that mdadm
> > insists that /dev/hda2 is not an md component.
> >
>
> As far as I know you have to use LILO instead of GRUB to boot
> from a root raid. Take care that raid1 is compiled into the kernel.
>
> --
> MfG / Regards
> Friedrich Lobenstock
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Raid1 and mdadm
@ 2003-03-31 17:22 Cress, Andrew R
2003-04-01 16:07 ` Paul Clements
0 siblings, 1 reply; 10+ messages in thread
From: Cress, Andrew R @ 2003-03-31 17:22 UTC (permalink / raw)
To: linux-raid
You can use grub for root mirroring (software raid-1), but grub currently
does not write the Master Boot Record to the 2nd disk, so you have to do
that manually the first time. Sample script below:
#
tmpa=/tmp/a
tmpg=/tmp/grub.out
cat - <<%%% >$tmpa
install (hd0,0)/grub/stage1 (hd1) (hd1,0)/grub/stage2 (hd0,0)/grub/grub.conf
quit
%%%
grub <$tmpa >$tmpg 2>&1
#
However, you MUST link the md driver into the kernel. It doesn't work right
as a module, even in initrd.
That's probably why it panic'd.
Andy
-----Original Message-----
From: Friedrich Lobenstock [mailto:fl@fl.priv.at]
Sent: Monday, March 31, 2003 6:35 AM
To: Linux RAID Mailing Liste
Subject: Re: Raid1 and mdadm
Max Booker wrote:
>
> GRUB boot loader
>
> hda1 /boot
> hda2 /
> hda3 swap
>
> hdd1 (intended) mirror partition of /
>
> I can create the (degraded) array on hdd1, mkfs on /dev/md0, mount
/dev/md0
> as /mnt, copy / to /mnt, and edit /mnt/etc/fstab.
>
> Everything works well up to the point where I reboot, with kernel
parameters
> (md=0,/dev/hdd1 root=/dev/md0). This is where the kernel panics.
>
> I think that I have not edited fstab properly, or GRUB is getting in the
> way, or maybe it is not possible to add hda2 to the array because it
already
> has a filesystem on it.... How do I get hda2 to be part of the Raid array?
> Nothing attempted so far has made any impression on the fact that mdadm
> insists that /dev/hda2 is not an md component.
>
As far as I know you have to use LILO instead of GRUB to boot
from a root raid. Take care that raid1 is compiled into the kernel.
--
MfG / Regards
Friedrich Lobenstock
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Raid1 and mdadm
2003-03-31 17:22 Raid1 and mdadm Cress, Andrew R
@ 2003-04-01 16:07 ` Paul Clements
2003-04-01 23:08 ` Neil Brown
0 siblings, 1 reply; 10+ messages in thread
From: Paul Clements @ 2003-04-01 16:07 UTC (permalink / raw)
To: linux-raid
"Cress, Andrew R" wrote:
> However, you MUST link the md driver into the kernel. It doesn't work right
> as a module, even in initrd.
BTW, it would be nice if this were fixed, so that md could be compiled
as a module...would the maintainers be willing to accept patches that
would make "autostart" a module option, so that upon insertion of the md
module it would do the autostart stuff, or something similar? From what
I can tell, we basically need to remove some ifndef MODULE stuff and
make the autostart option call autostart_arrays(), as it is when md is
linked into the kernel...
Or is there a better way to do this?
--
Paul
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Raid1 and mdadm
@ 2003-04-01 16:43 Cress, Andrew R
0 siblings, 0 replies; 10+ messages in thread
From: Cress, Andrew R @ 2003-04-01 16:43 UTC (permalink / raw)
To: 'Paul Clements', linux-raid
Well, it might be convenient otherwise, but it makes sense that if you want
to boot from the software RAID, that you have to ensure that the md driver
is loaded early enough to recognize that the RAID is configured before it
tries to boot from SCSI alone.
If you aren't booting from the software RAID, md can be a module.
Also, the other SCSI and RAID components can be modules as long as
CONFIG_BLK_DEV_MD=y.
Andy
-----Original Message-----
From: Paul Clements [mailto:Paul.Clements@SteelEye.com]
Sent: Tuesday, April 01, 2003 11:08 AM
To: linux-raid@vger.kernel.org
Subject: Re: Raid1 and mdadm
"Cress, Andrew R" wrote:
> However, you MUST link the md driver into the kernel. It doesn't work
right
> as a module, even in initrd.
BTW, it would be nice if this were fixed, so that md could be compiled
as a module...would the maintainers be willing to accept patches that
would make "autostart" a module option, so that upon insertion of the md
module it would do the autostart stuff, or something similar? From what
I can tell, we basically need to remove some ifndef MODULE stuff and
make the autostart option call autostart_arrays(), as it is when md is
linked into the kernel...
Or is there a better way to do this?
--
Paul
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Raid1 and mdadm
2003-04-01 16:07 ` Paul Clements
@ 2003-04-01 23:08 ` Neil Brown
2003-04-02 20:22 ` Paul Clements
0 siblings, 1 reply; 10+ messages in thread
From: Neil Brown @ 2003-04-01 23:08 UTC (permalink / raw)
To: Paul Clements; +Cc: linux-raid
On Tuesday April 1, Paul.Clements@SteelEye.com wrote:
> "Cress, Andrew R" wrote:
>
> > However, you MUST link the md driver into the kernel. It doesn't work right
> > as a module, even in initrd.
>
> BTW, it would be nice if this were fixed, so that md could be compiled
> as a module...would the maintainers be willing to accept patches that
> would make "autostart" a module option, so that upon insertion of the md
> module it would do the autostart stuff, or something similar? From what
> I can tell, we basically need to remove some ifndef MODULE stuff and
> make the autostart option call autostart_arrays(), as it is when md is
> linked into the kernel...
No. I would not accept patches.
Not because I fundamentally disagree with autostart, but because it
wouldn't work. I suggest you try it.
>
> Or is there a better way to do this?
Yes.
initrd/initfs is "the right way".
As far as I know, it *does* work.(*) You do not need md linked into the
kernel.
You have md.o and whatever personalities you want in the initrd image,
then in the initrd script (linuxrc I think) you load the modules, and
use mdadm to assemble the raid arrays.
You then mount the real root and off you go.
NeilBrown
(*) I say "as far as I know" because I have never tried it, because I
have not yet found the need. However I believe that others have been
successful.
I have perfectly happy compiling the raid driver into my kernels so
I have never bothered with initrd.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Raid1 and mdadm
2003-04-01 23:08 ` Neil Brown
@ 2003-04-02 20:22 ` Paul Clements
2003-04-02 20:34 ` Paul Clements
0 siblings, 1 reply; 10+ messages in thread
From: Paul Clements @ 2003-04-02 20:22 UTC (permalink / raw)
To: Neil Brown; +Cc: linux-raid
[-- Attachment #1: Type: text/plain, Size: 1556 bytes --]
Hi Neil,
> No. I would not accept patches.
> Not because I fundamentally disagree with autostart, but because it
> wouldn't work. I suggest you try it.
Maybe I didn't explain very clearly what my goal is...allow me to
clarify:
As it is now, if you compile md as a module and happen to have a
partition tagged as RAID, you'll panic the kernel. There's code in
fs/partitions (and in 2.5, in init/do_mounts.c) that is calling into
md....yechhh. What I'd like to do is make a clean separation between the
boot up and partitioning code and the md driver, so md can be compiled
as a module. (This would also allow other volume managers to use the
partition tagging to identify devices, if they wanted.)
> > Or is there a better way to do this?
>
> Yes.
> initrd/initfs is "the right way".
> As far as I know, it *does* work.(*) You do not need md linked into the
> kernel.
> You have md.o and whatever personalities you want in the initrd image,
> then in the initrd script (linuxrc I think) you load the modules, and
> use mdadm to assemble the raid arrays.
> You then mount the real root and off you go.
Right, sorry, I wasn't clear. This is basically what I meant. All I want
to do is allow autostart_arrays() to be called when md is compiled as a
module. Then, let the initrd/linuxrc (later initramfs) call
autostart_arrays() (ioctl("/dev/md0", RAID_AUTORUN) is all, really).
I've hacked on 2.5.63. I'll attach the patch, it's fairly short...and
might give you a better idea what I'm proposing...
Any comments would be appreciated.
Thanks,
Paul
[-- Attachment #2: md_modular_patch.diff --]
[-- Type: text/plain, Size: 5543 bytes --]
--- fs/partitions/Makefile.PRISTINE 2003-04-01 12:12:55.000000000 -0500
+++ fs/partitions/Makefile 2003-04-01 12:13:03.000000000 -0500
@@ -2,7 +2,7 @@
# Makefile for the linux kernel.
#
-obj-y := check.o
+obj-y := check.o raid.o
obj-$(CONFIG_ACORN_PARTITION) += acorn.o
obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
--- fs/partitions/check.c.PRISTINE 2003-04-01 12:14:12.000000000 -0500
+++ fs/partitions/check.c 2003-04-01 12:15:36.000000000 -0500
@@ -21,6 +21,7 @@
#include <linux/ctype.h>
#include "check.h"
+#include "raid.h"
#include "acorn.h"
#include "amiga.h"
@@ -35,10 +36,6 @@
#include "ultrix.h"
#include "efi.h"
-#if CONFIG_BLK_DEV_MD
-extern void md_autodetect_dev(dev_t dev);
-#endif
-
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
static int (*check_part[])(struct parsed_partitions *, struct block_device *) = {
@@ -423,7 +420,7 @@ void register_disk(struct gendisk *disk)
#if CONFIG_BLK_DEV_MD
if (!state->parts[j].flags)
continue;
- md_autodetect_dev(bdev->bd_dev+j);
+ raid_autodetect_dev(bdev->bd_dev+j);
#endif
}
kfree(state);
@@ -457,7 +454,7 @@ int rescan_partitions(struct gendisk *di
add_partition(disk, p, from, size);
#if CONFIG_BLK_DEV_MD
if (state->parts[p].flags)
- md_autodetect_dev(bdev->bd_dev+p);
+ raid_autodetect_dev(bdev->bd_dev+p);
#endif
}
kfree(state);
--- fs/partitions/check.c.PRISTINE 2003-04-01 12:14:12.000000000 -0500
+++ fs/partitions/check.c 2003-04-01 12:15:36.000000000 -0500
@@ -21,6 +21,7 @@
#include <linux/ctype.h>
#include "check.h"
+#include "raid.h"
#include "acorn.h"
#include "amiga.h"
@@ -35,10 +36,6 @@
#include "ultrix.h"
#include "efi.h"
-#if CONFIG_BLK_DEV_MD
-extern void md_autodetect_dev(dev_t dev);
-#endif
-
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
static int (*check_part[])(struct parsed_partitions *, struct block_device *) = {
@@ -423,7 +420,7 @@ void register_disk(struct gendisk *disk)
#if CONFIG_BLK_DEV_MD
if (!state->parts[j].flags)
continue;
- md_autodetect_dev(bdev->bd_dev+j);
+ raid_autodetect_dev(bdev->bd_dev+j);
#endif
}
kfree(state);
@@ -457,7 +454,7 @@ int rescan_partitions(struct gendisk *di
add_partition(disk, p, from, size);
#if CONFIG_BLK_DEV_MD
if (state->parts[p].flags)
- md_autodetect_dev(bdev->bd_dev+p);
+ raid_autodetect_dev(bdev->bd_dev+p);
#endif
}
kfree(state);
--- /dev/null 2002-12-05 15:33:16.000000000 -0500
+++ fs/partitions/raid.c 2003-04-01 13:16:53.000000000 -0500
@@ -0,0 +1,28 @@
+/*
+ * Save registered partitions that are marked as autorun RAID arrays.
+ *
+ * check.c saves the partitions by calling raid_autodetect_dev at boot time
+ * md.c uses the partition list to do its autostart_arrays
+ *
+ * code taken from md.c and new code added - 2003, Paul Clements
+ */
+static dev_t detected_devices[128];
+static int dev_cnt;
+
+void raid_autodetect_dev(dev_t dev)
+{
+ if (dev_cnt >= 0 && dev_cnt < 128)
+ detected_devices[dev_cnt++] = dev;
+}
+
+dev_t raid_get_detected_dev(int i)
+{
+ if (i >= 0 && i < dev_cnt)
+ return detected_devices[i];
+ return (dev_t) 0;
+}
+
+int raid_num_detected_devs(void)
+{
+ return dev_cnt;
+}
--- /dev/null 2002-12-05 15:33:16.000000000 -0500
+++ fs/partitions/raid.h 2003-04-01 12:17:30.000000000 -0500
@@ -0,0 +1,5 @@
+/*
+ * fs/partitions/raid.h
+ */
+
+void raid_autodetect_dev(dev_t dev);
--- drivers/md/md.c.PRISTINE 2003-04-01 11:37:58.000000000 -0500
+++ drivers/md/md.c 2003-04-02 09:59:10.000000000 -0500
@@ -59,9 +59,7 @@
#define dprintk(x...) ((void)(DEBUG && printk(x)))
-#ifndef MODULE
static void autostart_arrays (void);
-#endif
static mdk_personality_t *pers[MAX_PERSONALITY];
@@ -873,7 +871,9 @@ static void unlock_rdev(mdk_rdev_t *rdev
blkdev_put(bdev, BDEV_RAW);
}
-void md_autodetect_dev(dev_t dev);
+extern void raid_autodetect_dev(dev_t);
+extern dev_t raid_get_detected_dev(int);
+extern int raid_num_detected_devs(void);
static void export_rdev(mdk_rdev_t * rdev)
{
@@ -882,9 +882,7 @@ static void export_rdev(mdk_rdev_t * rde
MD_BUG();
free_disk_sb(rdev);
list_del_init(&rdev->same_set);
-#ifndef MODULE
- md_autodetect_dev(rdev->bdev->bd_dev);
-#endif
+ raid_autodetect_dev(rdev->bdev->bd_dev);
unlock_rdev(rdev);
kfree(rdev);
}
@@ -2225,12 +2223,10 @@ static int md_ioctl(struct inode *inode,
md_print_devices();
goto done;
-#ifndef MODULE
case RAID_AUTORUN:
err = 0;
autostart_arrays();
goto done;
-#endif
default:;
}
@@ -3237,23 +3233,11 @@ int __init md_init(void)
raid_table_header = register_sysctl_table(raid_root_table, 1);
md_geninit();
- return (0);
-}
-
-#ifndef MODULE
+ if (autostart)
+ autostart_arrays();
-/*
- * Searches all registered partitions for autorun RAID arrays
- * at boot time.
- */
-static dev_t detected_devices[128];
-static int dev_cnt;
-
-void md_autodetect_dev(dev_t dev)
-{
- if (dev_cnt >= 0 && dev_cnt < 127)
- detected_devices[dev_cnt++] = dev;
+ return (0);
}
@@ -3264,8 +3248,8 @@ static void autostart_arrays(void)
printk(KERN_INFO "md: Autodetecting RAID arrays.\n");
- for (i = 0; i < dev_cnt; i++) {
- dev_t dev = detected_devices[i];
+ for (i = 0; i < raid_num_detected_devs(); i++) {
+ dev_t dev = raid_get_detected_dev(i);
rdev = md_import_device(dev,1);
if (IS_ERR(rdev)) {
@@ -3284,8 +3268,6 @@ static void autostart_arrays(void)
autorun_devices();
}
-#endif
-
static __exit void md_exit(void)
{
int i;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Raid1 and mdadm
2003-04-02 20:22 ` Paul Clements
@ 2003-04-02 20:34 ` Paul Clements
0 siblings, 0 replies; 10+ messages in thread
From: Paul Clements @ 2003-04-02 20:34 UTC (permalink / raw)
To: Neil Brown, linux-raid
[-- Attachment #1: Type: text/plain, Size: 212 bytes --]
Paul Clements wrote:
> I've hacked on 2.5.63. I'll attach the patch, it's fairly short...and
> might give you a better idea what I'm proposing...
aghh...that patch is mangled...here's a better one... :)
--
Paul
[-- Attachment #2: md_modular_patch.diff --]
[-- Type: text/plain, Size: 4479 bytes --]
--- fs/partitions/Makefile.PRISTINE 2003-04-01 12:12:55.000000000 -0500
+++ fs/partitions/Makefile 2003-04-01 12:13:03.000000000 -0500
@@ -2,7 +2,7 @@
# Makefile for the linux kernel.
#
-obj-y := check.o
+obj-y := check.o raid.o
obj-$(CONFIG_ACORN_PARTITION) += acorn.o
obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
--- fs/partitions/check.c.PRISTINE 2003-04-01 12:14:12.000000000 -0500
+++ fs/partitions/check.c 2003-04-01 12:15:36.000000000 -0500
@@ -21,6 +21,7 @@
#include <linux/ctype.h>
#include "check.h"
+#include "raid.h"
#include "acorn.h"
#include "amiga.h"
@@ -35,10 +36,6 @@
#include "ultrix.h"
#include "efi.h"
-#if CONFIG_BLK_DEV_MD
-extern void md_autodetect_dev(dev_t dev);
-#endif
-
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
static int (*check_part[])(struct parsed_partitions *, struct block_device *) = {
@@ -423,7 +420,7 @@ void register_disk(struct gendisk *disk)
#if CONFIG_BLK_DEV_MD
if (!state->parts[j].flags)
continue;
- md_autodetect_dev(bdev->bd_dev+j);
+ raid_autodetect_dev(bdev->bd_dev+j);
#endif
}
kfree(state);
@@ -457,7 +454,7 @@ int rescan_partitions(struct gendisk *di
add_partition(disk, p, from, size);
#if CONFIG_BLK_DEV_MD
if (state->parts[p].flags)
- md_autodetect_dev(bdev->bd_dev+p);
+ raid_autodetect_dev(bdev->bd_dev+p);
#endif
}
kfree(state);
--- /dev/null 2002-12-05 15:33:16.000000000 -0500
+++ fs/partitions/raid.c 2003-04-01 13:16:53.000000000 -0500
@@ -0,0 +1,28 @@
+/*
+ * Save registered partitions that are marked as autorun RAID arrays.
+ *
+ * check.c saves the partitions by calling raid_autodetect_dev at boot time
+ * md.c uses the partition list to do its autostart_arrays
+ *
+ * code taken from md.c and new code added - 2003, Paul Clements
+ */
+static dev_t detected_devices[128];
+static int dev_cnt;
+
+void raid_autodetect_dev(dev_t dev)
+{
+ if (dev_cnt >= 0 && dev_cnt < 128)
+ detected_devices[dev_cnt++] = dev;
+}
+
+dev_t raid_get_detected_dev(int i)
+{
+ if (i >= 0 && i < dev_cnt)
+ return detected_devices[i];
+ return (dev_t) 0;
+}
+
+int raid_num_detected_devs(void)
+{
+ return dev_cnt;
+}
--- /dev/null 2002-12-05 15:33:16.000000000 -0500
+++ fs/partitions/raid.h 2003-04-01 12:17:30.000000000 -0500
@@ -0,0 +1,5 @@
+/*
+ * fs/partitions/raid.h
+ */
+
+void raid_autodetect_dev(dev_t dev);
--- drivers/md/md.c.PRISTINE 2003-04-01 11:37:58.000000000 -0500
+++ drivers/md/md.c 2003-04-02 09:59:10.000000000 -0500
@@ -59,9 +59,7 @@
#define dprintk(x...) ((void)(DEBUG && printk(x)))
-#ifndef MODULE
static void autostart_arrays (void);
-#endif
static mdk_personality_t *pers[MAX_PERSONALITY];
@@ -873,7 +871,9 @@ static void unlock_rdev(mdk_rdev_t *rdev
blkdev_put(bdev, BDEV_RAW);
}
-void md_autodetect_dev(dev_t dev);
+extern void raid_autodetect_dev(dev_t);
+extern dev_t raid_get_detected_dev(int);
+extern int raid_num_detected_devs(void);
static void export_rdev(mdk_rdev_t * rdev)
{
@@ -882,9 +882,7 @@ static void export_rdev(mdk_rdev_t * rde
MD_BUG();
free_disk_sb(rdev);
list_del_init(&rdev->same_set);
-#ifndef MODULE
- md_autodetect_dev(rdev->bdev->bd_dev);
-#endif
+ raid_autodetect_dev(rdev->bdev->bd_dev);
unlock_rdev(rdev);
kfree(rdev);
}
@@ -2225,12 +2223,10 @@ static int md_ioctl(struct inode *inode,
md_print_devices();
goto done;
-#ifndef MODULE
case RAID_AUTORUN:
err = 0;
autostart_arrays();
goto done;
-#endif
default:;
}
@@ -3237,23 +3233,11 @@ int __init md_init(void)
raid_table_header = register_sysctl_table(raid_root_table, 1);
md_geninit();
- return (0);
-}
-
-#ifndef MODULE
+ if (autostart)
+ autostart_arrays();
-/*
- * Searches all registered partitions for autorun RAID arrays
- * at boot time.
- */
-static dev_t detected_devices[128];
-static int dev_cnt;
-
-void md_autodetect_dev(dev_t dev)
-{
- if (dev_cnt >= 0 && dev_cnt < 127)
- detected_devices[dev_cnt++] = dev;
+ return (0);
}
@@ -3264,8 +3248,8 @@ static void autostart_arrays(void)
printk(KERN_INFO "md: Autodetecting RAID arrays.\n");
- for (i = 0; i < dev_cnt; i++) {
- dev_t dev = detected_devices[i];
+ for (i = 0; i < raid_num_detected_devs(); i++) {
+ dev_t dev = raid_get_detected_dev(i);
rdev = md_import_device(dev,1);
if (IS_ERR(rdev)) {
@@ -3284,8 +3268,6 @@ static void autostart_arrays(void)
autorun_devices();
}
-#endif
-
static __exit void md_exit(void)
{
int i;
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-04-02 20:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-31 17:22 Raid1 and mdadm Cress, Andrew R
2003-04-01 16:07 ` Paul Clements
2003-04-01 23:08 ` Neil Brown
2003-04-02 20:22 ` Paul Clements
2003-04-02 20:34 ` Paul Clements
-- strict thread matches above, loose matches on Subject: below --
2003-04-01 16:43 Cress, Andrew R
2003-03-31 13:33 Sarcar, Shourya C (MED)
2003-03-29 20:28 Max Booker
2003-03-29 21:54 ` Mads Peter Bach
2003-03-31 11:34 ` Friedrich Lobenstock
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).