Skip to content

Commit

Permalink
Make root mount timeout logic work for filesystems other than ufs.
Browse files Browse the repository at this point in the history
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


git-svn-id: svn+ssh://svn.freebsd.org/base/head@330745 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
  • Loading branch information
ian committed Mar 10, 2018
1 parent d502933 commit b13f0db
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions sys/kern/vfs_mountroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit b13f0db

Please sign in to comment.