]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/block/cfq-iosched.c
Merge master.kernel.org:/home/rmk/linux-2.6-serial
[karo-tx-linux.git] / drivers / block / cfq-iosched.c
index ff1cc968f96d12a573f84dbe77fcc2cf547460c3..cd056e7e64ec15d5cf81f16068623e29e07ad187 100644 (file)
@@ -47,7 +47,7 @@ static int cfq_slice_idle = HZ / 100;
 /*
  * disable queueing at the driver/hardware level
  */
-static int cfq_max_depth = 1;
+static int cfq_max_depth = 2;
 
 /*
  * for the hash of cfqq inside the cfqd
@@ -300,7 +300,6 @@ CFQ_CRQ_FNS(requeued);
 static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsigned short);
 static void cfq_dispatch_sort(request_queue_t *, struct cfq_rq *);
 static void cfq_put_cfqd(struct cfq_data *cfqd);
-static inline int cfq_pending_requests(struct cfq_data *cfqd);
 
 #define process_sync(tsk)      ((tsk)->flags & PF_SYNCWRITE)
 
@@ -348,6 +347,28 @@ static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
        return NULL;
 }
 
+static inline int cfq_pending_requests(struct cfq_data *cfqd)
+{
+       return !list_empty(&cfqd->queue->queue_head) || cfqd->busy_queues;
+}
+
+/*
+ * scheduler run of queue, if there are requests pending and no one in the
+ * driver that will restart queueing
+ */
+static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
+{
+       if (!cfqd->rq_in_driver && cfq_pending_requests(cfqd))
+               kblockd_schedule_work(&cfqd->unplug_work);
+}
+
+static int cfq_queue_empty(request_queue_t *q)
+{
+       struct cfq_data *cfqd = q->elevator->elevator_data;
+
+       return !cfq_pending_requests(cfqd);
+}
+
 /*
  * Lifted from AS - choose which of crq1 and crq2 that is best served now.
  * We choose the request that is closest to the head right now. Distance
@@ -364,9 +385,15 @@ cfq_choose_req(struct cfq_data *cfqd, struct cfq_rq *crq1, struct cfq_rq *crq2)
                return crq2;
        if (crq2 == NULL)
                return crq1;
-       if (cfq_crq_requeued(crq1))
+
+       if (cfq_crq_requeued(crq1) && !cfq_crq_requeued(crq2))
+               return crq1;
+       else if (cfq_crq_requeued(crq2) && !cfq_crq_requeued(crq1))
+               return crq2;
+
+       if (cfq_crq_is_sync(crq1) && !cfq_crq_is_sync(crq2))
                return crq1;
-       if (cfq_crq_requeued(crq2))
+       else if (cfq_crq_is_sync(crq2) && !cfq_crq_is_sync(crq1))
                return crq2;
 
        s1 = crq1->request->sector;
@@ -1071,16 +1098,6 @@ cfq_prio_to_maxrq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
        return 2 * (base_rq + base_rq * (CFQ_PRIO_LISTS - 1 - cfqq->ioprio));
 }
 
-/*
- * scheduler run of queue, if there are requests pending and no one in the
- * driver that will restart queueing
- */
-static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
-{
-       if (!cfqd->rq_in_driver && cfq_pending_requests(cfqd))
-               kblockd_schedule_work(&cfqd->unplug_work);
-}
-
 /*
  * get next queue for service
  */
@@ -1270,6 +1287,7 @@ dispatch:
                         */
                        if (!cfq_crq_in_driver(crq) &&
                            !cfq_cfqq_idle_window(cfqq) &&
+                           !blk_barrier_rq(rq) &&
                            cfqd->rq_in_driver >= cfqd->cfq_max_depth)
                                return NULL;
 
@@ -1757,18 +1775,23 @@ static void
 cfq_crq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
                 struct cfq_rq *crq)
 {
-       const int sync = cfq_crq_is_sync(crq);
+       struct cfq_io_context *cic;
 
        cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq);
 
-       if (sync) {
-               struct cfq_io_context *cic = crq->io_context;
+       /*
+        * we never wait for an async request and we don't allow preemption
+        * of an async request. so just return early
+        */
+       if (!cfq_crq_is_sync(crq))
+               return;
 
-               cfq_update_io_thinktime(cfqd, cic);
-               cfq_update_idle_window(cfqd, cfqq, cic);
+       cic = crq->io_context;
 
-               cic->last_queue = jiffies;
-       }
+       cfq_update_io_thinktime(cfqd, cic);
+       cfq_update_idle_window(cfqd, cfqq, cic);
+
+       cic->last_queue = jiffies;
 
        if (cfqq == cfqd->active_queue) {
                /*
@@ -1846,18 +1869,6 @@ cfq_insert_request(request_queue_t *q, struct request *rq, int where)
        }
 }
 
-static inline int cfq_pending_requests(struct cfq_data *cfqd)
-{
-       return !list_empty(&cfqd->queue->queue_head) || cfqd->busy_queues;
-}
-
-static int cfq_queue_empty(request_queue_t *q)
-{
-       struct cfq_data *cfqd = q->elevator->elevator_data;
-
-       return !cfq_pending_requests(cfqd);
-}
-
 static void cfq_completed_request(request_queue_t *q, struct request *rq)
 {
        struct cfq_rq *crq = RQ_DATA(rq);
@@ -1952,7 +1963,7 @@ __cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq,
 {
 #if 1
        if ((cfq_cfqq_wait_request(cfqq) || cfq_cfqq_must_alloc(cfqq)) &&
-           !cfq_cfqq_must_alloc_slice) {
+           !cfq_cfqq_must_alloc_slice(cfqq)) {
                cfq_mark_cfqq_must_alloc_slice(cfqq);
                return ELV_MQUEUE_MUST;
        }
@@ -1969,7 +1980,7 @@ __cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq,
                 * only allow 1 ELV_MQUEUE_MUST per slice, otherwise we
                 * can quickly flood the queue with writes from a single task
                 */
-               if (rw == READ || !cfq_cfqq_must_alloc_slice) {
+               if (rw == READ || !cfq_cfqq_must_alloc_slice(cfqq)) {
                        cfq_mark_cfqq_must_alloc_slice(cfqq);
                        return ELV_MQUEUE_MUST;
                }