Add cmpxchg_local to sparc64
[safe/jmp/linux-2.6] / block / cfq-iosched.c
index 8fe1a0d..ca198e6 100644 (file)
 /*
  * tunables
  */
-static const int cfq_quantum = 4;              /* max queue in one round of service */
+/* max queue in one round of service */
+static const int cfq_quantum = 4;
 static const int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 };
-static const int cfq_back_max = 16 * 1024;     /* maximum backwards seek, in KiB */
-static const int cfq_back_penalty = 2;         /* penalty of a backwards seek */
-
+/* maximum backwards seek, in KiB */
+static const int cfq_back_max = 16 * 1024;
+/* penalty of a backwards seek */
+static const int cfq_back_penalty = 2;
 static const int cfq_slice_sync = HZ / 10;
 static int cfq_slice_async = HZ / 25;
 static const int cfq_slice_async_rq = 2;
@@ -37,7 +39,8 @@ static int cfq_slice_idle = HZ / 125;
 
 #define CFQ_SLICE_SCALE                (5)
 
-#define RQ_CIC(rq)             ((struct cfq_io_context*)(rq)->elevator_private)
+#define RQ_CIC(rq)             \
+       ((struct cfq_io_context *) (rq)->elevator_private)
 #define RQ_CFQQ(rq)            ((rq)->elevator_private2)
 
 static struct kmem_cache *cfq_pool;
@@ -171,15 +174,15 @@ enum cfqq_state_flags {
 #define CFQ_CFQQ_FNS(name)                                             \
 static inline void cfq_mark_cfqq_##name(struct cfq_queue *cfqq)                \
 {                                                                      \
-       cfqq->flags |= (1 << CFQ_CFQQ_FLAG_##name);                     \
+       (cfqq)->flags |= (1 << CFQ_CFQQ_FLAG_##name);                   \
 }                                                                      \
 static inline void cfq_clear_cfqq_##name(struct cfq_queue *cfqq)       \
 {                                                                      \
-       cfqq->flags &= ~(1 << CFQ_CFQQ_FLAG_##name);                    \
+       (cfqq)->flags &= ~(1 << CFQ_CFQQ_FLAG_##name);                  \
 }                                                                      \
 static inline int cfq_cfqq_##name(const struct cfq_queue *cfqq)                \
 {                                                                      \
-       return (cfqq->flags & (1 << CFQ_CFQQ_FLAG_##name)) != 0;        \
+       return ((cfqq)->flags & (1 << CFQ_CFQQ_FLAG_##name)) != 0;      \
 }
 
 CFQ_CFQQ_FNS(on_rr);
@@ -534,8 +537,7 @@ static void cfq_resort_rr_list(struct cfq_data *cfqd, struct cfq_queue *cfqq)
  * add to busy list of queues for service, trying to be fair in ordering
  * the pending list according to last request service
  */
-static inline void
-cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+static void cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 {
        BUG_ON(cfq_cfqq_on_rr(cfqq));
        cfq_mark_cfqq_on_rr(cfqq);
@@ -548,8 +550,7 @@ cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
  * Called when the cfqq no longer has requests pending, remove it from
  * the service tree.
  */
-static inline void
-cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+static void cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 {
        BUG_ON(!cfq_cfqq_on_rr(cfqq));
        cfq_clear_cfqq_on_rr(cfqq);
@@ -564,7 +565,7 @@ cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 /*
  * rb tree support functions
  */
-static inline void cfq_del_rq_rb(struct request *rq)
+static void cfq_del_rq_rb(struct request *rq)
 {
        struct cfq_queue *cfqq = RQ_CFQQ(rq);
        struct cfq_data *cfqd = cfqq->cfqd;
@@ -604,8 +605,7 @@ static void cfq_add_rq_rb(struct request *rq)
        BUG_ON(!cfqq->next_rq);
 }
 
-static inline void
-cfq_reposition_rq_rb(struct cfq_queue *cfqq, struct request *rq)
+static void cfq_reposition_rq_rb(struct cfq_queue *cfqq, struct request *rq)
 {
        elv_rb_del(&cfqq->sort_list, rq);
        cfqq->queued[rq_is_sync(rq)]--;
@@ -742,8 +742,8 @@ static int cfq_allow_merge(struct request_queue *q, struct request *rq,
        return 0;
 }
 
-static inline void
-__cfq_set_active_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+static void __cfq_set_active_queue(struct cfq_data *cfqd,
+                                  struct cfq_queue *cfqq)
 {
        if (cfqq) {
                cfqq->slice_end = 0;
@@ -913,7 +913,7 @@ static void cfq_dispatch_insert(struct request_queue *q, struct request *rq)
 /*
  * return expired entry, or NULL to just start from scratch in rbtree
  */
-static inline struct request *cfq_check_fifo(struct cfq_queue *cfqq)
+static struct request *cfq_check_fifo(struct cfq_queue *cfqq)
 {
        struct cfq_data *cfqd = cfqq->cfqd;
        struct request *rq;
@@ -1008,7 +1008,8 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
                /*
                 * follow expired path, else get first next available
                 */
-               if ((rq = cfq_check_fifo(cfqq)) == NULL)
+               rq = cfq_check_fifo(cfqq);
+               if (rq == NULL)
                        rq = cfqq->next_rq;
 
                /*
@@ -1042,7 +1043,7 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
        return dispatched;
 }
 
-static inline int __cfq_forced_dispatch_cfqq(struct cfq_queue *cfqq)
+static int __cfq_forced_dispatch_cfqq(struct cfq_queue *cfqq)
 {
        int dispatched = 0;
 
@@ -1297,28 +1298,28 @@ static void cfq_init_prio_data(struct cfq_queue *cfqq, struct io_context *ioc)
 
        ioprio_class = IOPRIO_PRIO_CLASS(ioc->ioprio);
        switch (ioprio_class) {
-               default:
-                       printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class);
-               case IOPRIO_CLASS_NONE:
-                       /*
-                        * no prio set, place us in the middle of the BE classes
-                        */
-                       cfqq->ioprio = task_nice_ioprio(tsk);
-                       cfqq->ioprio_class = IOPRIO_CLASS_BE;
-                       break;
-               case IOPRIO_CLASS_RT:
-                       cfqq->ioprio = task_ioprio(ioc);
-                       cfqq->ioprio_class = IOPRIO_CLASS_RT;
-                       break;
-               case IOPRIO_CLASS_BE:
-                       cfqq->ioprio = task_ioprio(ioc);
-                       cfqq->ioprio_class = IOPRIO_CLASS_BE;
-                       break;
-               case IOPRIO_CLASS_IDLE:
-                       cfqq->ioprio_class = IOPRIO_CLASS_IDLE;
-                       cfqq->ioprio = 7;
-                       cfq_clear_cfqq_idle_window(cfqq);
-                       break;
+       default:
+               printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class);
+       case IOPRIO_CLASS_NONE:
+               /*
+                * no prio set, place us in the middle of the BE classes
+                */
+               cfqq->ioprio = task_nice_ioprio(tsk);
+               cfqq->ioprio_class = IOPRIO_CLASS_BE;
+               break;
+       case IOPRIO_CLASS_RT:
+               cfqq->ioprio = task_ioprio(ioc);
+               cfqq->ioprio_class = IOPRIO_CLASS_RT;
+               break;
+       case IOPRIO_CLASS_BE:
+               cfqq->ioprio = task_ioprio(ioc);
+               cfqq->ioprio_class = IOPRIO_CLASS_BE;
+               break;
+       case IOPRIO_CLASS_IDLE:
+               cfqq->ioprio_class = IOPRIO_CLASS_IDLE;
+               cfqq->ioprio = 7;
+               cfq_clear_cfqq_idle_window(cfqq);
+               break;
        }
 
        /*
@@ -1330,8 +1331,7 @@ static void cfq_init_prio_data(struct cfq_queue *cfqq, struct io_context *ioc)
        cfq_clear_cfqq_prio_changed(cfqq);
 }
 
-static inline void changed_ioprio(struct io_context *ioc,
-                                 struct cfq_io_context *cic)
+static void changed_ioprio(struct io_context *ioc, struct cfq_io_context *cic)
 {
        struct cfq_data *cfqd = cic->key;
        struct cfq_queue *cfqq;
@@ -1431,7 +1431,7 @@ out:
 static struct cfq_queue **
 cfq_async_queue_prio(struct cfq_data *cfqd, int ioprio_class, int ioprio)
 {
-       switch(ioprio_class) {
+       switch (ioprio_class) {
        case IOPRIO_CLASS_RT:
                return &cfqd->async_cfqq[0][ioprio];
        case IOPRIO_CLASS_BE:
@@ -1547,9 +1547,8 @@ cfq_cic_lookup(struct cfq_data *cfqd, struct io_context *ioc)
  * the process specific cfq io context when entered from the block layer.
  * Also adds the cic to a per-cfqd list, used when this queue is removed.
  */
-static inline int
-cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
-            struct cfq_io_context *cic, gfp_t gfp_mask)
+static int cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
+                       struct cfq_io_context *cic, gfp_t gfp_mask)
 {
        unsigned long flags;
        int ret;
@@ -2023,7 +2022,8 @@ static void cfq_idle_slice_timer(unsigned long data)
 
        spin_lock_irqsave(cfqd->queue->queue_lock, flags);
 
-       if ((cfqq = cfqd->active_queue) != NULL) {
+       cfqq = cfqd->active_queue;
+       if (cfqq) {
                timed_out = 0;
 
                /*
@@ -2217,14 +2217,18 @@ static ssize_t __FUNC(elevator_t *e, const char *page, size_t count)    \
        return ret;                                                     \
 }
 STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0);
-STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1, UINT_MAX, 1);
-STORE_FUNCTION(cfq_fifo_expire_async_store, &cfqd->cfq_fifo_expire[0], 1, UINT_MAX, 1);
+STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1,
+               UINT_MAX, 1);
+STORE_FUNCTION(cfq_fifo_expire_async_store, &cfqd->cfq_fifo_expire[0], 1,
+               UINT_MAX, 1);
 STORE_FUNCTION(cfq_back_seek_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0);
-STORE_FUNCTION(cfq_back_seek_penalty_store, &cfqd->cfq_back_penalty, 1, UINT_MAX, 0);
+STORE_FUNCTION(cfq_back_seek_penalty_store, &cfqd->cfq_back_penalty, 1,
+               UINT_MAX, 0);
 STORE_FUNCTION(cfq_slice_idle_store, &cfqd->cfq_slice_idle, 0, UINT_MAX, 1);
 STORE_FUNCTION(cfq_slice_sync_store, &cfqd->cfq_slice[1], 1, UINT_MAX, 1);
 STORE_FUNCTION(cfq_slice_async_store, &cfqd->cfq_slice[0], 1, UINT_MAX, 1);
-STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1, UINT_MAX, 0);
+STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1,
+               UINT_MAX, 0);
 #undef STORE_FUNCTION
 
 #define CFQ_ATTR(name) \