2002-06-02 20:12:50

by Paul Stoeber

[permalink] [raw]
Subject: patch to have root fs on USB device (please CC)

It simply sleeps 10 seconds before mount_block_root().

I get an 'Unable to mount root' panic if I don't apply it,
because the attached device rolls in too late.

Same for FireWire, but that's currently out of reach because
I must run rescan-scsi-bus.sh from user space to make the
disk visible as /dev/sd? (to be fixed soon??).

Same for all hotpluggable storage devices I suppose.

Of course that patch is really terribly wrong, maybe someone
will fix these things some day.

Please CC, I'm not on the list.


wait-before-mounting-root.patch in
Linux xyz 2.4.19-pre8 #2 Sun May 26 20:02:49 UTC 2002 ppc unknown

--- init/do_mounts.c.orig Sat May 25 18:11:45 2002
+++ init/do_mounts.c Sat May 25 18:15:22 2002
@@ -311,9 +311,13 @@
}
static void __init mount_block_root(char *name, int flags)
{
- char *fs_names = __getname();
+ char *fs_names;
char *p;

+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(10*HZ);
+
+ fs_names = __getname();
get_fs_names(fs_names);
retry:
for (p = fs_names; *p; p += strlen(p)+1) {


2002-06-02 20:47:02

by Thunder from the hill

[permalink] [raw]
Subject: Re: patch to have root fs on USB device (please CC)

Hi,

On Sun, 2 Jun 2002, Paul Stoeber wrote:
> --- init/do_mounts.c.orig Sat May 25 18:11:45 2002
> +++ init/do_mounts.c Sat May 25 18:15:22 2002
> @@ -311,9 +311,13 @@
> }
> static void __init mount_block_root(char *name, int flags)
> {
> - char *fs_names = __getname();
> + char *fs_names;
> char *p;
>
> + set_current_state(TASK_UNINTERRUPTIBLE);
> + schedule_timeout(10*HZ);
> +
> + fs_names = __getname();
> get_fs_names(fs_names);
> retry:
> for (p = fs_names; *p; p += strlen(p)+1) {

I think we shouldn't bind it on time but rather on whether the device is
available. Maybe check that instead of schedule_timeout(10*HZ)?

BTW, we stay in TASK_UNINTERRUPTIBLE here!

+ int i;
+
+ if (!(flags & SOMETHING_SAYING_WE_SHALL_NOT_INTERRUPT)) {
+ while (!path_lookup(name, LOOKUP_FOLLOW, &dummy)) {
+ i++;
+ printk(KERN_NOTICE "Root FS not yet available!\n");
+ if (i > 10)
+ break;
+
+ schedule_timeout(HZ/2);
+ }
+ }

or whatever.

Regards,
Thunder
--
ship is leaving right on time | Thunder from the hill at ngforever
empty harbour, wave goodbye |
evacuation of the isle | free inhabitant not directly
caveman's paintings drowning | belonging anywhere


2002-06-03 15:05:58

by Eric Lammerts

[permalink] [raw]
Subject: Re: patch to have root fs on USB device (please CC)


On Sun, Jun 02, 2002 at 10:13:22PM +0200, Paul Stoeber wrote:
> It simply sleeps 10 seconds before mount_block_root().
>
> I get an 'Unable to mount root' panic if I don't apply it,
> because the attached device rolls in too late.

A while ago I made the patch below. I retries every second until the root
device appears. Advantages:
- no delay when the device is already there
- it also works if it takes longer than 10s to find the harddisk
(for example, if you plug it in later)

I don't know if it applies cleanly to current kernels.

Eric

--- linux-2.4.14-pre8-ext3/fs/super.c.orig Fri Nov 16 00:59:18 2001
+++ linux-2.4.14-pre8-ext3/fs/super.c Fri Nov 16 01:07:26 2001
@@ -1009,11 +1009,13 @@
* Allow the user to distinguish between failed open
* and bad superblock on root device.
*/
- printk ("VFS: Cannot open root device \"%s\" or %s\n",
+ printk ("VFS: Cannot open root device \"%s\" or %s, retrying in 1s.\n",
root_device_name, kdevname (ROOT_DEV));
- printk ("Please append a correct \"root=\" boot option\n");
- panic("VFS: Unable to mount root fs on %s",
- kdevname(ROOT_DEV));
+
+ /* wait 1 second and try again */
+ current->state = TASK_INTERRUPTIBLE;
+ schedule_timeout(HZ);
+ goto retry;
}

check_disk_change(ROOT_DEV);