[PATCH] as-iosched: remove arq->is_sync member
[safe/jmp/linux-2.6] / block / as-iosched.c
index 134545b..dca0b05 100644 (file)
@@ -131,8 +131,6 @@ struct as_data {
        unsigned long antic_expire;
 };
 
-#define list_entry_fifo(ptr)   list_entry((ptr), struct as_rq, fifo)
-
 /*
  * per-request data.
  */
@@ -153,13 +151,6 @@ struct as_rq {
 
        struct io_context *io_context;  /* The submitting task */
 
-       /*
-        * expire fifo
-        */
-       struct list_head fifo;
-       unsigned long expires;
-
-       unsigned int is_sync;
        enum arq_state state;
 };
 
@@ -249,7 +240,7 @@ static void as_put_io_context(struct as_rq *arq)
 
        aic = arq->io_context->aic;
 
-       if (arq->is_sync == REQ_SYNC && aic) {
+       if (rq_is_sync(arq->request) && aic) {
                spin_lock(&aic->lock);
                set_bit(AS_TASK_IORUNNING, &aic->state);
                aic->last_end_request = jiffies;
@@ -262,14 +253,13 @@ static void as_put_io_context(struct as_rq *arq)
 /*
  * rb tree support functions
  */
-#define ARQ_RB_ROOT(ad, arq)   (&(ad)->sort_list[(arq)->is_sync])
+#define RQ_RB_ROOT(ad, rq)     (&(ad)->sort_list[rq_is_sync((rq))])
 
 static void as_add_arq_rb(struct as_data *ad, struct request *rq)
 {
-       struct as_rq *arq = RQ_DATA(rq);
        struct request *alias;
 
-       while ((unlikely(alias = elv_rb_add(ARQ_RB_ROOT(ad, arq), rq)))) {
+       while ((unlikely(alias = elv_rb_add(RQ_RB_ROOT(ad, rq), rq)))) {
                as_move_to_dispatch(ad, RQ_DATA(alias));
                as_antic_stop(ad);
        }
@@ -277,7 +267,7 @@ static void as_add_arq_rb(struct as_data *ad, struct request *rq)
 
 static inline void as_del_arq_rb(struct as_data *ad, struct request *rq)
 {
-       elv_rb_del(ARQ_RB_ROOT(ad, RQ_DATA(rq)), rq);
+       elv_rb_del(RQ_RB_ROOT(ad, rq), rq);
 }
 
 /*
@@ -308,13 +298,13 @@ as_choose_req(struct as_data *ad, struct as_rq *arq1, struct as_rq *arq2)
        if (arq2 == NULL)
                return arq1;
 
-       data_dir = arq1->is_sync;
+       data_dir = rq_is_sync(arq1->request);
 
        last = ad->last_sector[data_dir];
        s1 = arq1->request->sector;
        s2 = arq2->request->sector;
 
-       BUG_ON(data_dir != arq2->is_sync);
+       BUG_ON(data_dir != rq_is_sync(arq2->request));
 
        /*
         * Strict one way elevator _except_ in the case where we allow
@@ -385,7 +375,7 @@ static struct as_rq *as_find_next_arq(struct as_data *ad, struct as_rq *arq)
        if (rbnext)
                next = RQ_DATA(rb_entry_rq(rbnext));
        else {
-               const int data_dir = arq->is_sync;
+               const int data_dir = rq_is_sync(last);
 
                rbnext = rb_first(&ad->sort_list[data_dir]);
                if (rbnext && rbnext != &last->rb_node)
@@ -546,8 +536,7 @@ static void as_update_seekdist(struct as_data *ad, struct as_io_context *aic,
 static void as_update_iohist(struct as_data *ad, struct as_io_context *aic,
                                struct request *rq)
 {
-       struct as_rq *arq = RQ_DATA(rq);
-       int data_dir = arq->is_sync;
+       int data_dir = rq_is_sync(rq);
        unsigned long thinktime = 0;
        sector_t seek_dist;
 
@@ -682,7 +671,7 @@ static int as_can_break_anticipation(struct as_data *ad, struct as_rq *arq)
                return 1;
        }
 
-       if (arq && arq->is_sync == REQ_SYNC && as_close_req(ad, aic, arq)) {
+       if (arq && rq_is_sync(arq->request) && as_close_req(ad, aic, arq)) {
                /*
                 * Found a close request that is not one of ours.
                 *
@@ -766,7 +755,7 @@ static int as_can_anticipate(struct as_data *ad, struct as_rq *arq)
  */
 static void as_update_arq(struct as_data *ad, struct as_rq *arq)
 {
-       const int data_dir = arq->is_sync;
+       const int data_dir = rq_is_sync(arq->request);
 
        /* keep the next_arq cache up to date */
        ad->next_arq[data_dir] = as_choose_req(ad, arq, ad->next_arq[data_dir]);
@@ -843,7 +832,7 @@ static void as_completed_request(request_queue_t *q, struct request *rq)
         * actually serviced. This should help devices with big TCQ windows
         * and writeback caches
         */
-       if (ad->new_batch && ad->batch_data_dir == arq->is_sync) {
+       if (ad->new_batch && ad->batch_data_dir == rq_is_sync(rq)) {
                update_write_batch(ad);
                ad->current_batch_expires = jiffies +
                                ad->batch_expire[REQ_SYNC];
@@ -876,7 +865,7 @@ out:
 static void as_remove_queued_request(request_queue_t *q, struct request *rq)
 {
        struct as_rq *arq = RQ_DATA(rq);
-       const int data_dir = arq->is_sync;
+       const int data_dir = rq_is_sync(rq);
        struct as_data *ad = q->elevator->elevator_data;
 
        WARN_ON(arq->state != AS_RQ_QUEUED);
@@ -893,7 +882,7 @@ static void as_remove_queued_request(request_queue_t *q, struct request *rq)
        if (ad->next_arq[data_dir] == arq)
                ad->next_arq[data_dir] = as_find_next_arq(ad, arq);
 
-       list_del_init(&arq->fifo);
+       rq_fifo_clear(rq);
        as_del_arq_rb(ad, rq);
 }
 
@@ -907,7 +896,7 @@ static void as_remove_queued_request(request_queue_t *q, struct request *rq)
  */
 static int as_fifo_expired(struct as_data *ad, int adir)
 {
-       struct as_rq *arq;
+       struct request *rq;
        long delta_jif;
 
        delta_jif = jiffies - ad->last_check_fifo[adir];
@@ -921,9 +910,9 @@ static int as_fifo_expired(struct as_data *ad, int adir)
        if (list_empty(&ad->fifo_list[adir]))
                return 0;
 
-       arq = list_entry_fifo(ad->fifo_list[adir].next);
+       rq = rq_entry_fifo(ad->fifo_list[adir].next);
 
-       return time_after(jiffies, arq->expires);
+       return time_after(jiffies, rq_fifo_time(rq));
 }
 
 /*
@@ -949,7 +938,7 @@ static inline int as_batch_expired(struct as_data *ad)
 static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
 {
        struct request *rq = arq->request;
-       const int data_dir = arq->is_sync;
+       const int data_dir = rq_is_sync(rq);
 
        BUG_ON(RB_EMPTY_NODE(&rq->rb_node));
 
@@ -1089,7 +1078,7 @@ static int as_dispatch_request(request_queue_t *q, int force)
                        ad->changed_batch = 1;
                }
                ad->batch_data_dir = REQ_SYNC;
-               arq = list_entry_fifo(ad->fifo_list[ad->batch_data_dir].next);
+               arq = RQ_DATA(rq_entry_fifo(ad->fifo_list[REQ_SYNC].next));
                ad->last_check_fifo[ad->batch_data_dir] = jiffies;
                goto dispatch_request;
        }
@@ -1129,8 +1118,7 @@ dispatch_request:
 
        if (as_fifo_expired(ad, ad->batch_data_dir)) {
 fifo_expired:
-               arq = list_entry_fifo(ad->fifo_list[ad->batch_data_dir].next);
-               BUG_ON(arq == NULL);
+               arq = RQ_DATA(rq_entry_fifo(ad->fifo_list[ad->batch_data_dir].next));
        }
 
        if (ad->changed_batch) {
@@ -1167,12 +1155,7 @@ static void as_add_request(request_queue_t *q, struct request *rq)
 
        arq->state = AS_RQ_NEW;
 
-       if (rq_data_dir(arq->request) == READ
-                       || (arq->request->cmd_flags & REQ_RW_SYNC))
-               arq->is_sync = 1;
-       else
-               arq->is_sync = 0;
-       data_dir = arq->is_sync;
+       data_dir = rq_is_sync(rq);
 
        arq->io_context = as_get_io_context();
 
@@ -1186,8 +1169,8 @@ static void as_add_request(request_queue_t *q, struct request *rq)
        /*
         * set expire time (only used for reads) and add to fifo list
         */
-       arq->expires = jiffies + ad->fifo_expire[data_dir];
-       list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]);
+       rq_set_fifo_time(rq, jiffies + ad->fifo_expire[data_dir]);
+       list_add_tail(&rq->queuelist, &ad->fifo_list[data_dir]);
 
        as_update_arq(ad, arq); /* keep state machine up to date */
        arq->state = AS_RQ_QUEUED;
@@ -1277,10 +1260,10 @@ static void as_merged_requests(request_queue_t *q, struct request *req,
         * if anext expires before arq, assign its expire time to arq
         * and move into anext position (anext will be deleted) in fifo
         */
-       if (!list_empty(&arq->fifo) && !list_empty(&anext->fifo)) {
-               if (time_before(anext->expires, arq->expires)) {
-                       list_move(&arq->fifo, &anext->fifo);
-                       arq->expires = anext->expires;
+       if (!list_empty(&req->queuelist) && !list_empty(&next->queuelist)) {
+               if (time_before(rq_fifo_time(next), rq_fifo_time(req))) {
+                       list_move(&req->queuelist, &next->queuelist);
+                       rq_set_fifo_time(req, rq_fifo_time(next));
                        /*
                         * Don't copy here but swap, because when anext is
                         * removed below, it must contain the unused context
@@ -1350,7 +1333,6 @@ static int as_set_request(request_queue_t *q, struct request *rq,
                arq->request = rq;
                arq->state = AS_RQ_PRESCHED;
                arq->io_context = NULL;
-               INIT_LIST_HEAD(&arq->fifo);
                rq->elevator_private = arq;
                return 0;
        }