Skip to contentSkip to conversation

init/do_mounts.c: replace polling for root device with devtmpfs_wait_for_dev v1

PATCH In review [email protected] 2 participants 2 messages Aug 6, 2009 – Oct 9, 2009 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 init/do_mounts.c: replace polling for root device with devtmpfs_wait_for_dev v1

From: Ming Lei <[email protected]>

This patch removes the polling for root device if rootwait parameter is passed to kernel and CONFIG_DEVTMPFS is enabled. This way can lead to a faster boot, especially booting from some asynchronous block device (such as usb mass storage, mmc card, ...)

The patch has been verified in beagle board(mmc card as root device).

---
 init/do_mounts.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
init/do_mounts.c +16 -0
index aa56007..46f0248 100644
@@ -364,6 +364,7 @@ void __init mount_root(void)
 void __init prepare_namespace(void)
 {
 	int is_floppy;
+	int ret;
 
 	if (root_delay) {
 		printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
@@ -371,6 +372,7 @@ void __init prepare_namespace(void)
 		ssleep(root_delay);
 	}
 
+#ifndef CONFIG_DEVTMPFS
 	/*
 	 * wait for the known devices to complete their probing
 	 *
@@ -379,6 +381,7 @@ void __init prepare_namespace(void)
 	 * for the touchpad of a laptop to initialize.
 	 */
 	wait_for_device_probe();
+#endif
 
 	md_run_setup();
 
@@ -397,6 +400,7 @@ void __init prepare_namespace(void)
 	if (initrd_load())
 		goto out;
 
+#ifndef CONFIG_DEVTMPFS
 	/* wait for any asynchronous scanning to complete */
 	if ((ROOT_DEV == 0) && root_wait) {
 		printk(KERN_INFO "Waiting for root device %s...\n",
@@ -406,6 +410,18 @@ void __init prepare_namespace(void)
 			msleep(100);
 		async_synchronize_full();
 	}
+#else
+	/*wait for root device, and expire if 120 seconds elapse*/
+	if (!strncmp(saved_root_name, "/dev/", 5)) {
+		ret = devtmpfs_wait_for_dev(saved_root_name+5, 120);
+		printk(KERN_INFO "wait for %s based on devtmpfs:%d\n",
+			saved_root_name, ret);
+	}
+
+	ROOT_DEV = name_to_dev_t(saved_root_name);
+	if (!ROOT_DEV)
+		printk(KERN_ERR "Root device %s not found!\n", saved_root_name);
+#endif
 
 	is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
 
Signature · 1 line
1.6.0.GIT
#1 lore raw
Quoted 35 lines · On Thu, Aug 06, 2009 at 05:40:42PM +0800, [email protected] wrote:

From: Ming Lei <[email protected]>

This patch removes the polling for root device if rootwait parameter is passed to kernel and CONFIG_DEVTMPFS is enabled. This way can lead to a faster boot, especially booting from some asynchronous block device (such as usb mass storage, mmc card, ...)

The patch has been verified in beagle board(mmc card as root device).

---
 init/do_mounts.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
init/do_mounts.c +2 -0
index aa56007..46f0248 100644
@@ -364,6 +364,7 @@ void __init mount_root(void)
 void __init prepare_namespace(void)
 {
 	int is_floppy;
+	int ret;
 
 	if (root_delay) {
 		printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
@@ -371,6 +372,7 @@ void __init prepare_namespace(void)
 		ssleep(root_delay);
 	}
 
+#ifndef CONFIG_DEVTMPFS
 	/*
 	 * wait for the known devices to complete their probing
 	 *

init/do_mounts.c void __init prepare_namespace(void) · line 384

Quoted 4 lines
init/do_mounts.c +1 -0
@@ -379,6 +381,7 @@ void __init prepare_namespace(void)
 	 * for the touchpad of a laptop to initialize.
 	 */
 	wait_for_device_probe();
+#endif

Any way to do this without the #ifdef mess in the file? That's pretty ugly, and hard to maintain.

thanks,

greg k-h