tunnels: fix netns vs proto registration ordering
[safe/jmp/linux-2.6] / block / elevator.c
index 9189200..9ad5ccc 100644 (file)
 #include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/blktrace_api.h>
-#include <trace/block.h>
 #include <linux/hash.h>
 #include <linux/uaccess.h>
 
+#include <trace/events/block.h>
+
 #include "blk.h"
 
 static DEFINE_SPINLOCK(elv_list_lock);
 static LIST_HEAD(elv_list);
 
-DEFINE_TRACE(block_rq_abort);
-
 /*
  * Merge hash stuff.
  */
@@ -54,9 +53,6 @@ static const int elv_hash_shift = 6;
 #define ELV_HASH_ENTRIES       (1 << elv_hash_shift)
 #define rq_hash_key(rq)                (blk_rq_pos(rq) + blk_rq_sectors(rq))
 
-DEFINE_TRACE(block_rq_insert);
-DEFINE_TRACE(block_rq_issue);
-
 /*
  * Query io scheduler to see if the current process issuing bio may be
  * merged with rq.
@@ -83,7 +79,8 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio)
        /*
         * Don't merge file system requests and discard requests
         */
-       if (bio_discard(bio) != bio_discard(rq->bio))
+       if (bio_rw_flagged(bio, BIO_RW_DISCARD) !=
+           bio_rw_flagged(rq->bio, BIO_RW_DISCARD))
                return 0;
 
        /*
@@ -157,10 +154,7 @@ static struct elevator_type *elevator_get(const char *name)
 
                spin_unlock(&elv_list_lock);
 
-               if (!strcmp(name, "anticipatory"))
-                       sprintf(elv, "as-iosched");
-               else
-                       sprintf(elv, "%s-iosched", name);
+               sprintf(elv, "%s-iosched", name);
 
                request_module("%s", elv);
                spin_lock(&elv_list_lock);
@@ -196,10 +190,7 @@ static int __init elevator_setup(char *str)
         * Be backwards-compatible with previous kernels, so users
         * won't get the wrong elevator.
         */
-       if (!strcmp(str, "as"))
-               strcpy(chosen_elevator, "anticipatory");
-       else
-               strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
+       strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
        return 1;
 }
 
@@ -546,7 +537,7 @@ void elv_requeue_request(struct request_queue *q, struct request *rq)
         * in_flight count again
         */
        if (blk_account_rq(rq)) {
-               q->in_flight--;
+               q->in_flight[rq_is_sync(rq)]--;
                if (blk_sorted_rq(rq))
                        elv_deactivate_rq(q, rq);
        }
@@ -575,6 +566,9 @@ void elv_drain_elevator(struct request_queue *q)
  */
 void elv_quiesce_start(struct request_queue *q)
 {
+       if (!q->elevator)
+               return;
+
        queue_flag_set(QUEUE_FLAG_ELVSWITCH, q);
 
        /*
@@ -685,7 +679,7 @@ void elv_insert(struct request_queue *q, struct request *rq, int where)
 
        if (unplug_it && blk_queue_plugged(q)) {
                int nrq = q->rq.count[BLK_RW_SYNC] + q->rq.count[BLK_RW_ASYNC]
-                       - q->in_flight;
+                               - queue_in_flight(q);
 
                if (nrq >= q->unplug_thresh)
                        __generic_unplug_device(q);
@@ -810,6 +804,11 @@ void elv_abort_queue(struct request_queue *q)
                rq = list_entry_rq(q->queue_head.next);
                rq->cmd_flags |= REQ_QUIET;
                trace_block_rq_abort(q, rq);
+               /*
+                * Mark this request as started so we don't trigger
+                * any debug logic in the end I/O path.
+                */
+               blk_start_request(rq);
                __blk_end_request_all(rq, -EIO);
        }
 }
@@ -823,7 +822,7 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
         * request is released from the driver, io must be done
         */
        if (blk_account_rq(rq)) {
-               q->in_flight--;
+               q->in_flight[rq_is_sync(rq)]--;
                if (blk_sorted_rq(rq) && e->ops->elevator_completed_req_fn)
                        e->ops->elevator_completed_req_fn(q, rq);
        }
@@ -838,7 +837,7 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
                if (!list_empty(&q->queue_head))
                        next = list_entry_rq(q->queue_head.next);
 
-               if (!q->in_flight &&
+               if (!queue_in_flight(q) &&
                    blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN &&
                    (!next || blk_ordered_req_seq(next) > QUEUE_ORDSEQ_DRAIN)) {
                        blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0);
@@ -1050,10 +1049,11 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
        char elevator_name[ELV_NAME_MAX];
        struct elevator_type *e;
 
-       strlcpy(elevator_name, name, sizeof(elevator_name));
-       strstrip(elevator_name);
+       if (!q->elevator)
+               return count;
 
-       e = elevator_get(elevator_name);
+       strlcpy(elevator_name, name, sizeof(elevator_name));
+       e = elevator_get(strstrip(elevator_name));
        if (!e) {
                printk(KERN_ERR "elevator: type %s not found\n", elevator_name);
                return -EINVAL;
@@ -1073,10 +1073,15 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
 ssize_t elv_iosched_show(struct request_queue *q, char *name)
 {
        struct elevator_queue *e = q->elevator;
-       struct elevator_type *elv = e->elevator_type;
+       struct elevator_type *elv;
        struct elevator_type *__e;
        int len = 0;
 
+       if (!q->elevator)
+               return sprintf(name, "none\n");
+
+       elv = e->elevator_type;
+
        spin_lock(&elv_list_lock);
        list_for_each_entry(__e, &elv_list, list) {
                if (!strcmp(elv->elevator_name, __e->elevator_name))