Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Mar 2018 22:57:14 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r331276 - stable/10/sys/kern
Message-ID:  <201803202257.w2KMvEG7014833@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Tue Mar 20 22:57:14 2018
New Revision: 331276
URL: https://svnweb.freebsd.org/changeset/base/331276

Log:
  MFC r330745:
  
  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

Modified:
  stable/10/sys/kern/vfs_mountroot.c

Modified: stable/10/sys/kern/vfs_mountroot.c
==============================================================================
--- stable/10/sys/kern/vfs_mountroot.c	Tue Mar 20 22:57:06 2018	(r331275)
+++ stable/10/sys/kern/vfs_mountroot.c	Tue Mar 20 22:57:14 2018	(r331276)
@@ -741,15 +741,31 @@ 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);
+	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",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803202257.w2KMvEG7014833>