aboutsummaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
authorNate Diller <nate.diller@gmail.com>2006-01-24 04:07:58 -0500
committerJens Axboe <axboe@suse.de>2006-01-24 04:07:58 -0500
commit5f00397644e01adfbebafb5d0ebc01eba522709d (patch)
tree30fa87541eb60d74a0c6476a624d827c1da4dbce /block/elevator.c
parent53e86061b5bd4aece9bbb6b00b30720200596ecb (diff)
[BLOCK] elevator: default choice selection
My previous default iosched patch did a poor job dealing with the 'elevator=' boot-time option. The old behavior falls back to the compiled-in default if the requested one is not registered at boot time. This patch dynamically evaluates which default to use, and emits a suitable error message when the requested scheduler is not available. It also does the 'as' -> 'anticipatory' conversion before elevator registration, which along with a modified registration function, allows it to correctly indicate which default scheduler is in use. Tested for a range of boot options on 2.6.16-rc1-mm2. Signed-off-by: Nate Diller <nate.diller@gmail.com> Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c45
1 files changed, 14 insertions, 31 deletions
diff --git a/block/elevator.c b/block/elevator.c
index c9f424d5399c..dbbea73a8b10 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -139,35 +139,16 @@ static int elevator_attach(request_queue_t *q, struct elevator_type *e,
139 139
140static char chosen_elevator[16]; 140static char chosen_elevator[16];
141 141
142static void elevator_setup_default(void) 142static int __init elevator_setup(char *str)
143{ 143{
144 struct elevator_type *e;
145
146 /*
147 * If default has not been set, use the compiled-in selection.
148 */
149 if (!chosen_elevator[0])
150 strcpy(chosen_elevator, CONFIG_DEFAULT_IOSCHED);
151
152 /* 144 /*
153 * Be backwards-compatible with previous kernels, so users 145 * Be backwards-compatible with previous kernels, so users
154 * won't get the wrong elevator. 146 * won't get the wrong elevator.
155 */ 147 */
156 if (!strcmp(chosen_elevator, "as")) 148 if (!strcmp(str, "as"))
157 strcpy(chosen_elevator, "anticipatory"); 149 strcpy(chosen_elevator, "anticipatory");
158
159 /*
160 * If the given scheduler is not available, fall back to the default
161 */
162 if ((e = elevator_find(chosen_elevator)))
163 elevator_put(e);
164 else 150 else
165 strcpy(chosen_elevator, CONFIG_DEFAULT_IOSCHED); 151 strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
166}
167
168static int __init elevator_setup(char *str)
169{
170 strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
171 return 0; 152 return 0;
172} 153}
173 154
@@ -184,15 +165,15 @@ int elevator_init(request_queue_t *q, char *name)
184 q->end_sector = 0; 165 q->end_sector = 0;
185 q->boundary_rq = NULL; 166 q->boundary_rq = NULL;
186 167
187 elevator_setup_default(); 168 if (name && !(e = elevator_get(name)))
188
189 if (!name)
190 name = chosen_elevator;
191
192 e = elevator_get(name);
193 if (!e)
194 return -EINVAL; 169 return -EINVAL;
195 170
171 if (!e && !(e = elevator_get(chosen_elevator))) {
172 e = elevator_get(CONFIG_DEFAULT_IOSCHED);
173 if (*chosen_elevator)
174 printk("I/O scheduler %s not found\n", chosen_elevator);
175 }
176
196 eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL); 177 eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL);
197 if (!eq) { 178 if (!eq) {
198 elevator_put(e); 179 elevator_put(e);
@@ -669,8 +650,10 @@ int elv_register(struct elevator_type *e)
669 spin_unlock_irq(&elv_list_lock); 650 spin_unlock_irq(&elv_list_lock);
670 651
671 printk(KERN_INFO "io scheduler %s registered", e->elevator_name); 652 printk(KERN_INFO "io scheduler %s registered", e->elevator_name);
672 if (!strcmp(e->elevator_name, chosen_elevator)) 653 if (!strcmp(e->elevator_name, chosen_elevator) ||
673 printk(" (default)"); 654 (!*chosen_elevator &&
655 !strcmp(e->elevator_name, CONFIG_DEFAULT_IOSCHED)))
656 printk(" (default)");
674 printk("\n"); 657 printk("\n");
675 return 0; 658 return 0;
676} 659}