Provide an block queue init function that allows to set an elevator.
And a function to pin the current elevator.

Signed-off-by: Peter Zijlstra <[EMAIL PROTECTED]>
Signed-off-by: Daniel Phillips <[EMAIL PROTECTED]>
---
 block/elevator.c       |    5 +++++
 block/ll_rw_blk.c      |   12 ++++++++++--
 include/linux/blkdev.h |    9 +++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

Index: linux-2.6/block/ll_rw_blk.c
===================================================================
--- linux-2.6.orig/block/ll_rw_blk.c
+++ linux-2.6/block/ll_rw_blk.c
@@ -1899,6 +1899,14 @@ EXPORT_SYMBOL(blk_init_queue);
 request_queue_t *
 blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
 {
+       return blk_init_queue_node_elv(rfn, lock, node_id, NULL);
+}
+EXPORT_SYMBOL(blk_init_queue_node);
+
+request_queue_t *
+blk_init_queue_node_elv(request_fn_proc *rfn, spinlock_t *lock, int node_id,
+               char *elv_name)
+{
        request_queue_t *q = blk_alloc_queue_node(GFP_KERNEL, node_id);
 
        if (!q)
@@ -1939,7 +1947,7 @@ blk_init_queue_node(request_fn_proc *rfn
        /*
         * all done
         */
-       if (!elevator_init(q, NULL)) {
+       if (!elevator_init(q, elv_name)) {
                blk_queue_congestion_threshold(q);
                return q;
        }
@@ -1947,7 +1955,7 @@ blk_init_queue_node(request_fn_proc *rfn
        blk_put_queue(q);
        return NULL;
 }
-EXPORT_SYMBOL(blk_init_queue_node);
+EXPORT_SYMBOL(blk_init_queue_node_elv);
 
 int blk_get_queue(request_queue_t *q)
 {
Index: linux-2.6/include/linux/blkdev.h
===================================================================
--- linux-2.6.orig/include/linux/blkdev.h
+++ linux-2.6/include/linux/blkdev.h
@@ -444,6 +444,12 @@ struct request_queue
 #define QUEUE_FLAG_REENTER     6       /* Re-entrancy avoidance */
 #define QUEUE_FLAG_PLUGGED     7       /* queue is plugged */
 #define QUEUE_FLAG_ELVSWITCH   8       /* don't use elevator, just do FIFO */
+#define QUEUE_FLAG_ELVPINNED   9       /* pin the current elevator */
+
+static inline void blk_queue_pin_elevator(struct request_queue *q)
+{
+       set_bit(QUEUE_FLAG_ELVPINNED, &q->queue_flags);
+}
 
 enum {
        /*
@@ -696,6 +702,9 @@ static inline void elv_dispatch_add_tail
 /*
  * Access functions for manipulating queue properties
  */
+extern request_queue_t *blk_init_queue_node_elv(request_fn_proc *rfn,
+                                       spinlock_t *lock, int node_id,
+                                       char *elv_name);
 extern request_queue_t *blk_init_queue_node(request_fn_proc *rfn,
                                        spinlock_t *lock, int node_id);
 extern request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *);
Index: linux-2.6/block/elevator.c
===================================================================
--- linux-2.6.orig/block/elevator.c
+++ linux-2.6/block/elevator.c
@@ -861,6 +861,11 @@ ssize_t elv_iosched_store(request_queue_
        size_t len;
        struct elevator_type *e;
 
+       if (test_bit(QUEUE_FLAG_ELVPINNED, &q->queue_flags)) {
+               printk(KERN_NOTICE "elevator: cannot switch elevator, 
pinned\n");
+               return count;
+       }
+
        elevator_name[sizeof(elevator_name) - 1] = '\0';
        strncpy(elevator_name, name, sizeof(elevator_name) - 1);
        len = strlen(elevator_name);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to