Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 3701c60

Browse files
Christoph Hellwigaxboe
authored andcommitted
init: factor the root_wait logic in prepare_namespace into a helper
The root_wait logic is a bit obsfucated right now. Expand it and move it into a helper. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 07d63cb commit 3701c60

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

init/do_mounts.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,26 @@ void __init mount_root(char *root_device_name)
606606
}
607607
}
608608

609+
/* wait for any asynchronous scanning to complete */
610+
static void __init wait_for_root(char *root_device_name)
611+
{
612+
if (ROOT_DEV != 0)
613+
return;
614+
615+
pr_info("Waiting for root device %s...\n", root_device_name);
616+
617+
for (;;) {
618+
if (driver_probe_done()) {
619+
ROOT_DEV = name_to_dev_t(root_device_name);
620+
if (ROOT_DEV)
621+
break;
622+
}
623+
msleep(5);
624+
}
625+
async_synchronize_full();
626+
627+
}
628+
609629
static dev_t __init parse_root_device(char *root_device_name)
610630
{
611631
if (!strncmp(root_device_name, "mtd", 3) ||
@@ -642,16 +662,8 @@ void __init prepare_namespace(void)
642662
if (initrd_load(saved_root_name))
643663
goto out;
644664

645-
/* wait for any asynchronous scanning to complete */
646-
if ((ROOT_DEV == 0) && root_wait) {
647-
printk(KERN_INFO "Waiting for root device %s...\n",
648-
saved_root_name);
649-
while (!driver_probe_done() ||
650-
(ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
651-
msleep(5);
652-
async_synchronize_full();
653-
}
654-
665+
if (root_wait)
666+
wait_for_root(saved_root_name);
655667
mount_root(saved_root_name);
656668
out:
657669
devtmpfs_mount();

0 commit comments

Comments
 (0)