git: 972796d007c2 - stable/13 - vfs_mountroot: Check for root dev before waiting

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Wed, 12 Jan 2022 19:31:01 UTC
The branch stable/13 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=972796d007c2bda481f50cf99d5531d5754ef2fa

commit 972796d007c2bda481f50cf99d5531d5754ef2fa
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2021-12-20 17:55:36 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2022-01-12 19:29:51 +0000

    vfs_mountroot: Check for root dev before waiting
    
    If GEOM is idle but the root device is not yet present when we enter
    vfs_mountroot_wait_if_necessary, we call vfs_mountroot_wait to wait
    for root holds (e.g. CAM or USB initialization).  Upon returning from
    vfs_mountroot_wait, we wait 100 ms at a time until the root device
    shows up.
    
    Since the root device most likely appeared during vfs_mountroot_wait
    -- waiting for subsystems which may be responsible for the root
    device is the whole purpose of that function -- it makes sense to
    check if the device is now present rather than printing a warning
    and pausing for 100 ms before checking.
    
    Reviewed by:    trasz
    Fixes: a3ba3d09c248 Make root mount wait mechanism smarter
    Sponsored by:   https://www.patreon.com/cperciva
    Differential Revision:  https://reviews.freebsd.org/D33593
    
    (cherry picked from commit 33812d60b9601d7ef8a7222c063696bfd6a77f41)
---
 sys/kern/vfs_mountroot.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c
index 851a9c839669..7e88a58fdb90 100644
--- a/sys/kern/vfs_mountroot.c
+++ b/sys/kern/vfs_mountroot.c
@@ -1041,6 +1041,8 @@ vfs_mountroot_wait_if_neccessary(const char *fs, const char *dev)
 	 * to behave exactly as it used to work before.
 	 */
 	vfs_mountroot_wait();
+	if (parse_mount_dev_present(dev))
+		return (0);
 	printf("mountroot: waiting for device %s...\n", dev);
 	delay = hz / 10;
 	timeout = root_mount_timeout * hz;