summaryrefslogtreecommitdiffstats
path: root/init/do_mounts.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-05-31 14:55:22 +0200
committerJens Axboe <axboe@kernel.dk>2023-06-05 18:55:20 +0200
commit3701c600a3e735b9fbac6f7a73e4c086090c97ca (patch)
tree48995fd55af5becc6ca06e3882d586e5d217aa93 /init/do_mounts.c
parentinit: handle ubi/mtd root mounting like all other root types (diff)
downloadlinux-3701c600a3e735b9fbac6f7a73e4c086090c97ca.tar.xz
linux-3701c600a3e735b9fbac6f7a73e4c086090c97ca.zip
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 <hch@lst.de> Link: https://lore.kernel.org/r/20230531125535.676098-12-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'init/do_mounts.c')
-rw-r--r--init/do_mounts.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c
index be6d14733ba0..d5c06c1546e8 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -606,6 +606,26 @@ void __init mount_root(char *root_device_name)
}
}
+/* wait for any asynchronous scanning to complete */
+static void __init wait_for_root(char *root_device_name)
+{
+ if (ROOT_DEV != 0)
+ return;
+
+ pr_info("Waiting for root device %s...\n", root_device_name);
+
+ for (;;) {
+ if (driver_probe_done()) {
+ ROOT_DEV = name_to_dev_t(root_device_name);
+ if (ROOT_DEV)
+ break;
+ }
+ msleep(5);
+ }
+ async_synchronize_full();
+
+}
+
static dev_t __init parse_root_device(char *root_device_name)
{
if (!strncmp(root_device_name, "mtd", 3) ||
@@ -642,16 +662,8 @@ void __init prepare_namespace(void)
if (initrd_load(saved_root_name))
goto out;
- /* wait for any asynchronous scanning to complete */
- if ((ROOT_DEV == 0) && root_wait) {
- printk(KERN_INFO "Waiting for root device %s...\n",
- saved_root_name);
- while (!driver_probe_done() ||
- (ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
- msleep(5);
- async_synchronize_full();
- }
-
+ if (root_wait)
+ wait_for_root(saved_root_name);
mount_root(saved_root_name);
out:
devtmpfs_mount();