diff options
-rw-r--r-- | block/elevator.c | 16 | ||||
-rw-r--r-- | include/linux/elevator.h | 5 | ||||
-rw-r--r-- | include/linux/init.h | 1 | ||||
-rw-r--r-- | init/do_mounts_initrd.c | 3 | ||||
-rw-r--r-- | init/initramfs.c | 8 | ||||
-rw-r--r-- | init/main.c | 16 |
6 files changed, 48 insertions, 1 deletions
diff --git a/block/elevator.c b/block/elevator.c index 9edba1b8323e..c2d61d56e0b7 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -136,6 +136,22 @@ static int __init elevator_setup(char *str) | |||
136 | 136 | ||
137 | __setup("elevator=", elevator_setup); | 137 | __setup("elevator=", elevator_setup); |
138 | 138 | ||
139 | /* called during boot to load the elevator chosen by the elevator param */ | ||
140 | void __init load_default_elevator_module(void) | ||
141 | { | ||
142 | struct elevator_type *e; | ||
143 | |||
144 | if (!chosen_elevator[0]) | ||
145 | return; | ||
146 | |||
147 | spin_lock(&elv_list_lock); | ||
148 | e = elevator_find(chosen_elevator); | ||
149 | spin_unlock(&elv_list_lock); | ||
150 | |||
151 | if (!e) | ||
152 | request_module("%s-iosched", chosen_elevator); | ||
153 | } | ||
154 | |||
139 | static struct kobj_type elv_ktype; | 155 | static struct kobj_type elv_ktype; |
140 | 156 | ||
141 | static struct elevator_queue *elevator_alloc(struct request_queue *q, | 157 | static struct elevator_queue *elevator_alloc(struct request_queue *q, |
diff --git a/include/linux/elevator.h b/include/linux/elevator.h index c03af7687bb4..186620631750 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h | |||
@@ -138,6 +138,7 @@ extern void elv_drain_elevator(struct request_queue *); | |||
138 | /* | 138 | /* |
139 | * io scheduler registration | 139 | * io scheduler registration |
140 | */ | 140 | */ |
141 | extern void __init load_default_elevator_module(void); | ||
141 | extern int elv_register(struct elevator_type *); | 142 | extern int elv_register(struct elevator_type *); |
142 | extern void elv_unregister(struct elevator_type *); | 143 | extern void elv_unregister(struct elevator_type *); |
143 | 144 | ||
@@ -206,5 +207,9 @@ enum { | |||
206 | INIT_LIST_HEAD(&(rq)->csd.list); \ | 207 | INIT_LIST_HEAD(&(rq)->csd.list); \ |
207 | } while (0) | 208 | } while (0) |
208 | 209 | ||
210 | #else /* CONFIG_BLOCK */ | ||
211 | |||
212 | static inline void load_default_elevator_module(void) { } | ||
213 | |||
209 | #endif /* CONFIG_BLOCK */ | 214 | #endif /* CONFIG_BLOCK */ |
210 | #endif | 215 | #endif |
diff --git a/include/linux/init.h b/include/linux/init.h index a799273714ac..9230c9408d8b 100644 --- a/include/linux/init.h +++ b/include/linux/init.h | |||
@@ -161,6 +161,7 @@ extern unsigned int reset_devices; | |||
161 | /* used by init/main.c */ | 161 | /* used by init/main.c */ |
162 | void setup_arch(char **); | 162 | void setup_arch(char **); |
163 | void prepare_namespace(void); | 163 | void prepare_namespace(void); |
164 | void __init load_default_modules(void); | ||
164 | 165 | ||
165 | extern void (*late_time_init)(void); | 166 | extern void (*late_time_init)(void); |
166 | 167 | ||
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 5e4ded51788e..dfe606a7dd61 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c | |||
@@ -57,6 +57,9 @@ static void __init handle_initrd(void) | |||
57 | sys_mkdir("/old", 0700); | 57 | sys_mkdir("/old", 0700); |
58 | sys_chdir("/old"); | 58 | sys_chdir("/old"); |
59 | 59 | ||
60 | /* try loading default modules from initrd */ | ||
61 | load_default_modules(); | ||
62 | |||
60 | /* | 63 | /* |
61 | * In case that a resume from disk is carried out by linuxrc or one of | 64 | * In case that a resume from disk is carried out by linuxrc or one of |
62 | * its children, we need to tell the freezer not to wait for us. | 65 | * its children, we need to tell the freezer not to wait for us. |
diff --git a/init/initramfs.c b/init/initramfs.c index 84c6bf111300..a67ef9dbda9d 100644 --- a/init/initramfs.c +++ b/init/initramfs.c | |||
@@ -592,7 +592,7 @@ static int __init populate_rootfs(void) | |||
592 | initrd_end - initrd_start); | 592 | initrd_end - initrd_start); |
593 | if (!err) { | 593 | if (!err) { |
594 | free_initrd(); | 594 | free_initrd(); |
595 | return 0; | 595 | goto done; |
596 | } else { | 596 | } else { |
597 | clean_rootfs(); | 597 | clean_rootfs(); |
598 | unpack_to_rootfs(__initramfs_start, __initramfs_size); | 598 | unpack_to_rootfs(__initramfs_start, __initramfs_size); |
@@ -607,6 +607,7 @@ static int __init populate_rootfs(void) | |||
607 | sys_close(fd); | 607 | sys_close(fd); |
608 | free_initrd(); | 608 | free_initrd(); |
609 | } | 609 | } |
610 | done: | ||
610 | #else | 611 | #else |
611 | printk(KERN_INFO "Unpacking initramfs...\n"); | 612 | printk(KERN_INFO "Unpacking initramfs...\n"); |
612 | err = unpack_to_rootfs((char *)initrd_start, | 613 | err = unpack_to_rootfs((char *)initrd_start, |
@@ -615,6 +616,11 @@ static int __init populate_rootfs(void) | |||
615 | printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); | 616 | printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); |
616 | free_initrd(); | 617 | free_initrd(); |
617 | #endif | 618 | #endif |
619 | /* | ||
620 | * Try loading default modules from initramfs. This gives | ||
621 | * us a chance to load before device_initcalls. | ||
622 | */ | ||
623 | load_default_modules(); | ||
618 | } | 624 | } |
619 | return 0; | 625 | return 0; |
620 | } | 626 | } |
diff --git a/init/main.c b/init/main.c index baf1f0f5c461..18efadb11cf6 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -70,6 +70,8 @@ | |||
70 | #include <linux/perf_event.h> | 70 | #include <linux/perf_event.h> |
71 | #include <linux/file.h> | 71 | #include <linux/file.h> |
72 | #include <linux/ptrace.h> | 72 | #include <linux/ptrace.h> |
73 | #include <linux/blkdev.h> | ||
74 | #include <linux/elevator.h> | ||
73 | 75 | ||
74 | #include <asm/io.h> | 76 | #include <asm/io.h> |
75 | #include <asm/bugs.h> | 77 | #include <asm/bugs.h> |
@@ -794,6 +796,17 @@ static void __init do_pre_smp_initcalls(void) | |||
794 | do_one_initcall(*fn); | 796 | do_one_initcall(*fn); |
795 | } | 797 | } |
796 | 798 | ||
799 | /* | ||
800 | * This function requests modules which should be loaded by default and is | ||
801 | * called twice right after initrd is mounted and right before init is | ||
802 | * exec'd. If such modules are on either initrd or rootfs, they will be | ||
803 | * loaded before control is passed to userland. | ||
804 | */ | ||
805 | void __init load_default_modules(void) | ||
806 | { | ||
807 | load_default_elevator_module(); | ||
808 | } | ||
809 | |||
797 | static int run_init_process(const char *init_filename) | 810 | static int run_init_process(const char *init_filename) |
798 | { | 811 | { |
799 | argv_init[0] = init_filename; | 812 | argv_init[0] = init_filename; |
@@ -898,4 +911,7 @@ static void __init kernel_init_freeable(void) | |||
898 | * we're essentially up and running. Get rid of the | 911 | * we're essentially up and running. Get rid of the |
899 | * initmem segments and start the user-mode stuff.. | 912 | * initmem segments and start the user-mode stuff.. |
900 | */ | 913 | */ |
914 | |||
915 | /* rootfs is available now, try loading default modules */ | ||
916 | load_default_modules(); | ||
901 | } | 917 | } |