diff options
author | trasz <trasz@FreeBSD.org> | 2015-10-30 15:52:10 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2015-10-30 15:52:10 +0000 |
commit | e52d6f1e4a485dde1baf3a1e057bcdbf73ebbf7b (patch) | |
tree | de89f37ec395b87059ddc577708871cb63ebb789 /etc/rc.d/mountcritlocal | |
parent | 3b970d7ccc00f84d53bef1b8094f2907ff67b750 (diff) | |
download | FreeBSD-src-e52d6f1e4a485dde1baf3a1e057bcdbf73ebbf7b.zip FreeBSD-src-e52d6f1e4a485dde1baf3a1e057bcdbf73ebbf7b.tar.gz |
After r290196, the kernel won't wait for stuff like gmirror nodes
if they are not required for mounting rootfs. However, it's possible
that some setups try to mount them in mountcritlocal (ie from fstab).
Export the list of current root mount holds using a new sysctl,
vfs.root_mount_hold, and make mountcritlocal retry if "mount -a" fails
and the list is not empty.
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3709
Diffstat (limited to 'etc/rc.d/mountcritlocal')
-rwxr-xr-x | etc/rc.d/mountcritlocal | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/etc/rc.d/mountcritlocal b/etc/rc.d/mountcritlocal index 06bf464..1513ec7 100755 --- a/etc/rc.d/mountcritlocal +++ b/etc/rc.d/mountcritlocal @@ -15,7 +15,7 @@ stop_cmd=sync mountcritlocal_start() { - local err + local err holders waited # Set up the list of network filesystem types for which mounting # should be delayed until after network initialization. @@ -35,8 +35,42 @@ mountcritlocal_start() mount_excludes="${mount_excludes}${fstype}," done mount_excludes=${mount_excludes%,} + + # Originally, root mount hold had to be released before mounting the root + # filesystem. This delayed the boot, so it was changed to only wait if + # the root device isn't readily available. This can result in this script + # executing before all the devices - such as graid(8) - are available. + # Thus, should the mount fail, we will wait for the root mount hold release + # and retry. mount -a -t ${mount_excludes} err=$? + if [ $? -ne 0 ]; then + echo + echo 'Mounting /etc/fstab filesystems failed,' \ + 'will retry after root mount hold release' + + waited=0 + while [ ${waited} -lt ${root_hold_delay} ]; do + holders="$(sysctl -n vfs.root_mount_hold)" + if [ -z "${holders}" ]; then + break; + fi + if [ ${waited} -eq 0 ]; then + echo -n "Waiting ${root_hold_delay}s" \ + "for the root mount holders: ${holders}" + else + echo -n . + fi + if [ ${waited} -eq ${root_hold_delay} ]; then + break 2 + fi + sleep 1 + waited=$(($waited + 1)) + done + mount -a -t ${mount_excludes} + err=$? + fi + check_startmsgs && echo '.' case ${err} in @@ -44,7 +78,7 @@ mountcritlocal_start() ;; *) echo 'Mounting /etc/fstab filesystems failed,' \ - ' startup aborted' + 'startup aborted' stop_boot true ;; esac |