misc/144695: race condition in mounting a root-fs on an
external usb-disk
Garrett Cooper
yanefbsd at gmail.com
Fri Mar 12 22:20:04 UTC 2010
The following reply was made to PR kern/144695; it has been noted by GNATS.
From: Garrett Cooper <yanefbsd at gmail.com>
To: Torsten <tkalix at bredex.de>
Cc: freebsd-gnats-submit at freebsd.org
Subject: Re: misc/144695: race condition in mounting a root-fs on an external
usb-disk
Date: Fri, 12 Mar 2010 14:18:44 -0800
On Fri, Mar 12, 2010 at 6:27 AM, Torsten <tkalix at bredex.de> wrote:
>
>>Number: =A0 =A0 =A0 =A0 144695
>>Category: =A0 =A0 =A0 misc
>>Synopsis: =A0 =A0 =A0 race condition in mounting a root-fs on an external=
usb-disk
>>Confidential: =A0 no
>>Severity: =A0 =A0 =A0 non-critical
>>Priority: =A0 =A0 =A0 low
>>Responsible: =A0 =A0freebsd-bugs
>>State: =A0 =A0 =A0 =A0 =A0open
>>Quarter:
>>Keywords:
>>Date-Required:
>>Class: =A0 =A0 =A0 =A0 =A0sw-bug
>>Submitter-Id: =A0 current-users
>>Arrival-Date: =A0 Fri Mar 12 14:30:03 UTC 2010
>>Closed-Date:
>>Last-Modified:
>>Originator: =A0 =A0 Torsten
>>Release: =A0 =A0 =A0 =A0freebsd 8.0 release
>>Organization:
> n/a
>>Environment:
>>Description:
> Hello!
>
> I have installed FreeBSD 8 on my external usb-harddisk without any proble=
ms. Just I cannot boot into it, but I always receive a mountroot-prompt.
> Reading the news / archives I found a problem in the mountroot taking pla=
ce too early -- before all of the usb-probe and device-setup is fully done.
> There was (?) no really solution available, so I have made a small change=
that caused everything to work -- but one may see this more a work-around =
than rather a real fix.
> The main idea is to put in an un-conditional wait at the beginning of vfs=
_mountroot. And, of course make this configurable. The acutal change is jus=
t a few lines that should not harm anything else.
> For my system I have started with the default of 5000ms, but I needed to =
go to 15000ms to mount my root-fs safely.
> Please find attached the source-diff.
>>How-To-Repeat:
>
>>Fix:
> FreeBSD unixrest 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Fri Mar 12 14:02:27 =
CET 2010 =A0 =A0 root at unixrest:/usr/src/sys/i386/compile/BXGENERIC =A0i386
>
>
> Patch attached with submission follows:
>
> --- vfs_mount.c.orig =A0 =A02010-03-12 13:02:33.000000000 +0100
> +++ vfs_mount.c 2010-03-12 13:56:04.000000000 +0100
> @@ -1648,6 +1648,12 @@
>
> =A0 =A0 =A0 =A0options =3D NULL;
>
> + =A0 =A0 =A0 =A0static int mountroot_wait_delay =3D 5000;
> + =A0 =A0 =A0 =A0TUNABLE_INT_FETCH("hw.mountroot_wait_delay", &mountroot_=
wait_delay);
> + =A0 =A0 =A0 int mysec =3D mountroot_wait_delay / hz;
> + =A0 =A0 =A0 printf("Waiting %d seconds for devices to settle.\n", mysec=
);
> + =A0 =A0 =A0 =A0pause("Waiting for devices to settle", mountroot_wait_de=
lay);
> +
> =A0 =A0 =A0 =A0root_mount_prepare();
>
> =A0 =A0 =A0 =A0mount_zone =3D uma_zcreate("Mountpoints", sizeof(struct mo=
unt),
> @@ -2492,3 +2498,4 @@
> =A0 =A0 =A0 =A0error =3D kernel_mount(ma, flags);
> =A0 =A0 =A0 =A0return (error);
> =A0}
> +
1. This was misfiled (should be under kern).
2. This is a well-known issue (devices in general not being available
by the time mount of mountroot is attempted) that isn't trivial to
resolve.
3. mav@ has a more scalable solution offered here that's been
committed into CURRENT in the past couple months:
http://www.mail-archive.com/freebsd-stable@freebsd.org/msg107696.html
. Look for kern.cam.boot_delay.
HTH,
-Garrett
More information about the freebsd-bugs
mailing list