Make root mount timeout logic work for filesystems other than ufs.

The vfs.mountroot.timeout tunable and .timeout directive in a mount.conf(5)
file allow specifying a wait timeout for the device(s) hosting the root
filesystem to become usable.  The current mechanism for waiting for devices
and detecting their availability can't be used for zfs-hosted filesystems.
See the comment #20 in the PR for some expanded detail on these points.

This change adds retry logic to the actual root filesystem mount.  That is,
insted of relying on device availability using device name lookups, it uses
the kernel_mount() call itself to detect whether the filesystem can be
mounted, and loops until it succeeds or the configured timeout is exceeded.

These changes are based on the patch attached to the PR, but it's rewritten
enough that all mistakes belong to me.

PR:		208882
X-MFC after:	sufficient testing, and hopefully in time for 11.1
This commit is contained in:
ian 2018-03-10 22:07:57 +00:00
parent e25476465d
commit 8b0ba03b3f

View File

@ -714,7 +714,7 @@ parse_mount(char **conf)
char *errmsg;
struct mntarg *ma;
char *dev, *fs, *opts, *tok;
int error;
int delay, error, timeout;
error = parse_token(conf, &tok);
if (error)
@ -755,15 +755,31 @@ parse_mount(char **conf)
if (error != 0)
goto out;
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);
delay = hz / 10;
timeout = root_mount_timeout * hz;
for (;;) {
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 (error == 0 || timeout <= 0)
break;
if (root_mount_timeout * hz == timeout ||
(bootverbose && timeout % hz == 0)) {
printf("Mounting from %s:%s failed with error %d; "
"retrying for %d more second%s\n", fs, dev, error,
timeout / hz, (timeout / hz > 1) ? "s" : "");
}
pause("rmretry", delay);
timeout -= delay;
}
out:
if (error) {
printf("Mounting from %s:%s failed with error %d",