]> err.no Git - linux-2.6/commitdiff
[PATCH] stop elv_unregister() from rogering other iosched's data, fix locking
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 18 Mar 2006 18:21:20 +0000 (13:21 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 18 Mar 2006 23:34:12 +0000 (18:34 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
block/as-iosched.c
block/cfq-iosched.c
block/elevator.c
include/linux/elevator.h

index 8da3cf66894c379b1b4908d94602c49f77cb473e..d2ee2af44b589ecb0e6976797b23165ababb39c1 100644 (file)
@@ -195,6 +195,12 @@ static void free_as_io_context(struct as_io_context *aic)
        kfree(aic);
 }
 
+static void as_trim(struct io_context *ioc)
+{
+       kfree(ioc->aic);
+       ioc->aic = NULL;
+}
+
 /* Called when the task exits */
 static void exit_as_io_context(struct as_io_context *aic)
 {
@@ -1860,6 +1866,7 @@ static struct elevator_type iosched_as = {
                .elevator_may_queue_fn =        as_may_queue,
                .elevator_init_fn =             as_init_queue,
                .elevator_exit_fn =             as_exit_queue,
+               .trim =                         as_trim,
        },
 
        .elevator_ktype = &as_ktype,
index 521c56d4fdbc238b75c7e88ed24259faec263536..7102bafc98b39faa70cbf25ade4edeee011d277f 100644 (file)
@@ -1211,6 +1211,13 @@ static void cfq_free_io_context(struct cfq_io_context *cic)
        kmem_cache_free(cfq_ioc_pool, cic);
 }
 
+static void cfq_trim(struct io_context *ioc)
+{
+       ioc->set_ioprio = NULL;
+       if (ioc->cic)
+               cfq_free_io_context(ioc->cic);
+}
+
 /*
  * Called with interrupts disabled
  */
@@ -2472,6 +2479,7 @@ static struct elevator_type iosched_cfq = {
                .elevator_may_queue_fn =        cfq_may_queue,
                .elevator_init_fn =             cfq_init_queue,
                .elevator_exit_fn =             cfq_exit_queue,
+               .trim =                         cfq_trim,
        },
        .elevator_ktype =       &cfq_ktype,
        .elevator_name =        "cfq",
index 24b702d649a953977cafb7125ca1b81d73947cc3..0232df2b16e6a9bbec94606554a5fd1dc0357961 100644 (file)
@@ -675,21 +675,15 @@ void elv_unregister(struct elevator_type *e)
        /*
         * Iterate every thread in the process to remove the io contexts.
         */
-       read_lock(&tasklist_lock);
-       do_each_thread(g, p) {
-               struct io_context *ioc = p->io_context;
-               if (ioc && ioc->cic) {
-                       ioc->cic->exit(ioc->cic);
-                       ioc->cic->dtor(ioc->cic);
-                       ioc->cic = NULL;
-               }
-               if (ioc && ioc->aic) {
-                       ioc->aic->exit(ioc->aic);
-                       ioc->aic->dtor(ioc->aic);
-                       ioc->aic = NULL;
-               }
-       } while_each_thread(g, p);
-       read_unlock(&tasklist_lock);
+       if (e->ops.trim) {
+               read_lock(&tasklist_lock);
+               do_each_thread(g, p) {
+                       task_lock(p);
+                       e->ops.trim(p->io_context);
+                       task_unlock(p);
+               } while_each_thread(g, p);
+               read_unlock(&tasklist_lock);
+       }
 
        spin_lock_irq(&elv_list_lock);
        list_del_init(&e->list);
index 18cf1f3e11845dd6ba28f81b3defd2e4ed52adff..f65766ef053290ba94c93a5302c891e150284563 100644 (file)
@@ -48,6 +48,7 @@ struct elevator_ops
 
        elevator_init_fn *elevator_init_fn;
        elevator_exit_fn *elevator_exit_fn;
+       void (*trim)(struct io_context *);
 };
 
 #define ELV_NAME_MAX   (16)