]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - block/elevator.c
block: unify flags for struct bio and struct request
[net-next-2.6.git] / block / elevator.c
index 6df2b5056b51e1347c10cb7c5f3c50d09aa21650..816a7c8d6394257d89fb36bd67c6b01a62d92020 100644 (file)
@@ -79,8 +79,7 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio)
        /*
         * Don't merge file system requests and discard requests
         */
-       if (bio_rw_flagged(bio, BIO_RW_DISCARD) !=
-           bio_rw_flagged(rq->bio, BIO_RW_DISCARD))
+       if ((bio->bi_rw & REQ_DISCARD) != (rq->bio->bi_rw & REQ_DISCARD))
                return 0;
 
        /*
@@ -242,9 +241,11 @@ int elevator_init(struct request_queue *q, char *name)
 {
        struct elevator_type *e = NULL;
        struct elevator_queue *eq;
-       int ret = 0;
        void *data;
 
+       if (unlikely(q->elevator))
+               return 0;
+
        INIT_LIST_HEAD(&q->queue_head);
        q->last_merge = NULL;
        q->end_sector = 0;
@@ -284,7 +285,7 @@ int elevator_init(struct request_queue *q, char *name)
        }
 
        elevator_attach(q, eq, data);
-       return ret;
+       return 0;
 }
 EXPORT_SYMBOL(elevator_init);
 
@@ -426,7 +427,8 @@ void elv_dispatch_sort(struct request_queue *q, struct request *rq)
        list_for_each_prev(entry, &q->queue_head) {
                struct request *pos = list_entry_rq(entry);
 
-               if (blk_discard_rq(rq) != blk_discard_rq(pos))
+               if ((rq->cmd_flags & REQ_DISCARD) !=
+                   (pos->cmd_flags & REQ_DISCARD))
                        break;
                if (rq_data_dir(rq) != rq_data_dir(pos))
                        break;
@@ -556,7 +558,7 @@ void elv_requeue_request(struct request_queue *q, struct request *rq)
         */
        if (blk_account_rq(rq)) {
                q->in_flight[rq_is_sync(rq)]--;
-               if (blk_sorted_rq(rq))
+               if (rq->cmd_flags & REQ_SORTED)
                        elv_deactivate_rq(q, rq);
        }
 
@@ -642,7 +644,8 @@ void elv_insert(struct request_queue *q, struct request *rq, int where)
                break;
 
        case ELEVATOR_INSERT_SORT:
-               BUG_ON(!blk_fs_request(rq) && !blk_discard_rq(rq));
+               BUG_ON(rq->cmd_type != REQ_TYPE_FS &&
+                      !(rq->cmd_flags & REQ_DISCARD));
                rq->cmd_flags |= REQ_SORTED;
                q->nr_sorted++;
                if (rq_mergeable(rq)) {
@@ -714,7 +717,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where,
                /*
                 * toggle ordered color
                 */
-               if (blk_barrier_rq(rq))
+               if (rq->cmd_flags & REQ_HARDBARRIER)
                        q->ordcolor ^= 1;
 
                /*
@@ -727,7 +730,8 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where,
                 * this request is scheduling boundary, update
                 * end_sector
                 */
-               if (blk_fs_request(rq) || blk_discard_rq(rq)) {
+               if (rq->cmd_type == REQ_TYPE_FS ||
+                   (rq->cmd_flags & REQ_DISCARD)) {
                        q->end_sector = rq_end_sector(rq);
                        q->boundary_rq = rq;
                }
@@ -841,7 +845,8 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
         */
        if (blk_account_rq(rq)) {
                q->in_flight[rq_is_sync(rq)]--;
-               if (blk_sorted_rq(rq) && e->ops->elevator_completed_req_fn)
+               if ((rq->cmd_flags & REQ_SORTED) &&
+                   e->ops->elevator_completed_req_fn)
                        e->ops->elevator_completed_req_fn(q, rq);
        }
 
@@ -1097,7 +1102,7 @@ ssize_t elv_iosched_show(struct request_queue *q, char *name)
        struct elevator_type *__e;
        int len = 0;
 
-       if (!q->elevator)
+       if (!q->elevator || !blk_queue_stackable(q))
                return sprintf(name, "none\n");
 
        elv = e->elevator_type;