public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Default iosched fixes (was: Fall back io scheduler for 2.6.15?)
@ 2006-01-20  0:04 Nate Diller
  2006-01-20  8:11 ` Jens Axboe
  0 siblings, 1 reply; 8+ messages in thread
From: Nate Diller @ 2006-01-20  0:04 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Andrew Morton, cmm, seelam, linux-kernel, ext2-devel

My previous default iosched patch did a poor job dealing with the
'elevator=' boot-time option.  Jens' recent solution would fail if the
selected default were compiled as a module, and I find that scenario
useful for debugging.  This patch dynamically evaluates which default
to use, and emits suitable error messages when the requested scheduler
is not available.  It also indicates the compiled-in default scheduler
at registration time, and includes a version of Chuck Ebbert's 'as' ->
'anticipatory' compatability patch.

Tested for a range of boot options on 2.6.13-rc5-mm1, should apply to
any recent kernel.

Signed-off-by: Nate Diller <nate.diller@gmail.com>

--- drivers/block/elevator.c	2006-01-19 15:01:03.000000000 -0800
+++ drivers/block/elevator.c	2006-01-19 15:03:22.000000000 -0800
@@ -153,27 +153,16 @@ static int elevator_attach(request_queue

 static char chosen_elevator[16];

-static void elevator_setup_default(void)
+static int __init elevator_setup(char *str)
 {
-	struct elevator_type *e;
-
 	/*
-	 * If default has not been set, use the compiled-in selection.
+	 * Be backwards-compatible with previous kernels, so users
+	 * won't get the wrong scheduler.
 	 */
-	if (!chosen_elevator[0])
-		strcpy(chosen_elevator, CONFIG_DEFAULT_IOSCHED);
-
- 	/*
- 	 * If the given scheduler is not available, fall back to no-op.
- 	 */
- 	if (!(e = elevator_find(chosen_elevator)))
- 		strcpy(chosen_elevator, "noop");
-	elevator_put(e);
-}
-
-static int __init elevator_setup(char *str)
-{
-	strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
+	if (!strcmp(str, "as"))
+		strcpy(chosen_elevator, "anticipatory");
+	else
+		strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
 	return 0;
 }

@@ -185,14 +174,16 @@ int elevator_init(request_queue_t *q, ch
 	struct elevator_queue *eq;
 	int ret = 0;

-	elevator_setup_default();
+	if (name && !(e = elevator_get(name)))
+		return -EINVAL;

-	if (!name)
-		name = chosen_elevator;
+	if (!e && chosen_elevator[0] && !(e = elevator_get(chosen_elevator)))
+		printk("I/O scheduler %s not found\n", chosen_elevator);

-	e = elevator_get(name);
-	if (!e)
-		return -EINVAL;
+	if (!e && !(e = elevator_get(CONFIG_DEFAULT_IOSCHED))) {
+		e = elevator_get("noop");
+		printk("Default I/O scheduler not found, using no-op\n");
+	}

 	eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL);
 	if (!eq) {
@@ -566,7 +557,9 @@ int elv_register(struct elevator_type *e
 	spin_unlock_irq(&elv_list_lock);

 	printk(KERN_INFO "io scheduler %s registered", e->elevator_name);
-	if (!strcmp(e->elevator_name, chosen_elevator))
+	if (!strcmp(e->elevator_name, chosen_elevator) ||
+			(!chosen_elevator[0] &&
+			 !strcmp(e->elevator_name, CONFIG_DEFAULT_IOSCHED)))
 		printk(" (default)");
 	printk("\n");
 	return 0;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-01-23 21:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-20  0:04 [PATCH] Default iosched fixes (was: Fall back io scheduler for 2.6.15?) Nate Diller
2006-01-20  8:11 ` Jens Axboe
2006-01-20 23:17   ` [PATCH 1/2][RESEND] " Nate Diller
2006-01-20 23:24     ` [PATCH 2/2][RESEND] " Nate Diller
2006-01-21 11:40       ` Jens Axboe
2006-01-21 11:48     ` [PATCH 1/2][RESEND] " Jens Axboe
2006-01-23 19:50       ` Nate Diller
2006-01-23 21:02         ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox