[PATCH] Allow populate_rootfs() to be called early (resent, with sob)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Éric Piel
Date: Saturday, February 23, 2008 - 12:40 pm

21/02/08 20:02, Éric Piel wrote/a écrit:
Len has reminded me that I have to add a s-o-b line to my patches :-)
Here is a corrected version (against 2.6.25-rc2).

Eric 
--

For ACPI table override, we need the rootfs available early. So this patch
* removes the kludge calling populate_rootfs early _sometimes_
* leverage the usermodehelper_disabled variable to prevent too early userspace
  execution would could lead to oops if the kernel subsystem are not yet initialised

Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net>
---
 include/asm-generic/vmlinux.lds.h |    1 -
 include/linux/init.h              |    1 -
 init/initramfs.c                  |    7 -------
 init/main.c                       |    4 ----
 kernel/kmod.c                     |   15 +++++++++++----
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index f784d2f..19ddbae 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -335,7 +335,6 @@
   	*(.initcall4s.init)						\
   	*(.initcall5.init)						\
   	*(.initcall5s.init)						\
-	*(.initcallrootfs.init)						\
   	*(.initcall6.init)						\
   	*(.initcall6s.init)						\
   	*(.initcall7.init)						\
diff --git a/include/linux/init.h b/include/linux/init.h
index a404a00..ecd05cd 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -183,7 +183,6 @@ void prepare_namespace(void);
 #define subsys_initcall_sync(fn)	__define_initcall("4s",fn,4s)
 #define fs_initcall(fn)			__define_initcall("5",fn,5)
 #define fs_initcall_sync(fn)		__define_initcall("5s",fn,5s)
-#define rootfs_initcall(fn)		__define_initcall("rootfs",fn,rootfs)
 #define device_initcall(fn)		__define_initcall("6",fn,6)
 #define device_initcall_sync(fn)	__define_initcall("6s",fn,6s)
 #define late_initcall(fn)		__define_initcall("7",fn,7)
diff --git a/init/initramfs.c b/init/initramfs.c
index c0b1e05..b74e845 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -577,10 +577,3 @@ int __init populate_rootfs(void)
 	}
 	return 0;
 }
-#ifndef CONFIG_ACPI_CUSTOM_DSDT_INITRD
-/*
- * if this option is enabled, populate_rootfs() is called _earlier_ in the
- * boot sequence. This insures that the ACPI initialisation can find the file.
- */
-rootfs_initcall(populate_rootfs);
-#endif
diff --git a/init/main.c b/init/main.c
index 8b19820..703ded0 100644
--- a/init/main.c
+++ b/init/main.c
@@ -102,11 +102,7 @@ static inline void mark_rodata_ro(void) { }
 extern void tc_init(void);
 #endif
 
-#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
 extern int populate_rootfs(void);
-#else
-static inline void populate_rootfs(void) {}
-#endif
 
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);
diff --git a/kernel/kmod.c b/kernel/kmod.c
index bb7df2a..112b261 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -267,14 +267,23 @@ static void __call_usermodehelper(struct work_struct *work)
 	}
 }
 
-#ifdef CONFIG_PM
 /*
  * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
  * (used for preventing user land processes from being created after the user
  * land has been frozen during a system-wide hibernation or suspend operation).
+ * It is also used at boot up to avoid calling a user land process before all
+ * the kernel subsystems are initialised (such as pipefs).
  */
-static int usermodehelper_disabled;
+static int usermodehelper_disabled = 1;
 
+static int __init enable_usermodehelper(void)
+{
+	usermodehelper_disabled = 0;
+	return 0;
+}
+fs_initcall_sync(enable_usermodehelper);
+
+#ifdef CONFIG_PM
 /* Number of helpers running */
 static atomic_t running_helpers = ATOMIC_INIT(0);
 
@@ -342,8 +351,6 @@ static void register_pm_notifier_callback(void)
 	pm_notifier(usermodehelper_pm_callback, 0);
 }
 #else /* CONFIG_PM */
-#define usermodehelper_disabled	0
-
 static inline void helper_lock(void) {}
 static inline void helper_unlock(void) {}
 static inline void register_pm_notifier_callback(void) {}

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
acpi dsts loading and populate_rootfs, Christoph Hellwig, (Sun Feb 10, 12:12 am)
Re: acpi dsts loading and populate_rootfs, Christoph Hellwig, (Sun Feb 10, 12:14 am)
Re: acpi dsts loading and populate_rootfs, Eric Piel, (Sun Feb 10, 4:58 am)
Re: acpi dsts loading and populate_rootfs, Sergey Vlasov, (Mon Feb 11, 6:47 am)
Re: acpi dsts loading and populate_rootfs, Éric Piel, (Mon Feb 11, 4:41 pm)
Re: acpi dsts loading and populate_rootfs, Christoph Hellwig, (Mon Feb 11, 10:37 pm)
Re: acpi dsts loading and populate_rootfs, Éric Piel, (Thu Feb 21, 11:46 am)
Re: [PATCH] Allow populate_rootfs() to be called early (wa ..., Christoph Hellwig, (Thu Feb 21, 12:04 pm)
Re: acpi dsts loading and populate_rootfs, Thomas Renninger, (Fri Feb 22, 1:51 am)
Re: acpi dsts loading and populate_rootfs, Thomas Renninger, (Fri Feb 22, 2:05 am)
Re: acpi dsts loading and populate_rootfs, Andi Kleen, (Fri Feb 22, 2:53 am)
[PATCH] Allow populate_rootfs() to be called early (resent ..., Éric Piel, (Sat Feb 23, 12:40 pm)
Re: [PATCH] Use userland-like functions for reading the AC ..., Christoph Hellwig, (Sat Feb 23, 6:31 pm)