From 865f13d3a5ca0468ec0f21ad9287d79f6c6d0129 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 18 Mar 2015 13:08:28 +0100 Subject: [PATCH] parse_mount(): Use vfs.mountroot.timeout for ZFS root pools as well Instead of trying to figure out the required vdevs to wait for, just call kernel_mount() until it works or the time is up. Fancier approaches are conceivable ... If the current approach is kept, it may make sense to add a flag to tell kernel_mount() not to free the mount args. As an alternative the retrying could be delegated to kernel_mount() itself. Obtained from: ElectroBSD --- sys/kern/vfs_mountroot.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c index a050099..b049bb7 100644 --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -713,11 +713,12 @@ parse_mount(char **conf) goto out; } + delay = hz / 10; + timeout = root_mount_timeout * hz; + if (strcmp(fs, "zfs") != 0 && strstr(fs, "nfs") == NULL && dev[0] != '\0' && !parse_mount_dev_present(dev)) { printf("mountroot: waiting for device %s ...\n", dev); - delay = hz / 10; - timeout = root_mount_timeout * hz; do { pause("rmdev", delay); timeout -= delay; @@ -728,15 +729,26 @@ parse_mount(char **conf) } } - ma = NULL; - ma = mount_arg(ma, "fstype", fs, -1); - ma = mount_arg(ma, "fspath", "/", -1); - ma = mount_arg(ma, "from", dev, -1); - ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL); - ma = mount_arg(ma, "ro", NULL, 0); - ma = parse_mountroot_options(ma, opts); - error = kernel_mount(ma, MNT_ROOTFS); - + do { + ma = NULL; + ma = mount_arg(ma, "fstype", fs, -1); + ma = mount_arg(ma, "fspath", "/", -1); + ma = mount_arg(ma, "from", dev, -1); + ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL); + ma = mount_arg(ma, "ro", NULL, 0); + ma = parse_mountroot_options(ma, opts); + + error = kernel_mount(ma, MNT_ROOTFS); + if (strcmp(fs, "zfs") != 0) + break; + timeout -= delay; + if (timeout > 0 && error) { + pause("rmdev", delay); + printf("Mounting from %s:%s failed with error %d. " + "%d seconds left. Retrying.\n", fs, dev, error, + timeout / hz); + } + } while (timeout > 0 && error); out: if (error) { printf("Mounting from %s:%s failed with error %d", -- 2.3.0