|
@@ -2863,3 +2863,86 @@ static bool cfq_may_dispatch(struct cfq_data *cfqd, struct cfq_queue *cfqq)
|
|
*/
|
|
*/
|
|
if (!cfq_cfqq_sync(cfqq) && cfqd->cfq_latency) {
|
|
if (!cfq_cfqq_sync(cfqq) && cfqd->cfq_latency) {
|
|
unsigned long last_sync = jiffies - cfqd->last_delayed_sync;
|
|
unsigned long last_sync = jiffies - cfqd->last_delayed_sync;
|
|
|
|
+ unsigned int depth;
|
|
|
|
+
|
|
|
|
+ depth = last_sync / cfqd->cfq_slice[1];
|
|
|
|
+ if (!depth && !cfqq->dispatched)
|
|
|
|
+ depth = 1;
|
|
|
|
+ if (depth < max_dispatch)
|
|
|
|
+ max_dispatch = depth;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * If we're below the current max, allow a dispatch
|
|
|
|
+ */
|
|
|
|
+ return cfqq->dispatched < max_dispatch;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Dispatch a request from cfqq, moving them to the request queue
|
|
|
|
+ * dispatch list.
|
|
|
|
+ */
|
|
|
|
+static bool cfq_dispatch_request(struct cfq_data *cfqd, struct cfq_queue *cfqq)
|
|
|
|
+{
|
|
|
|
+ struct request *rq;
|
|
|
|
+
|
|
|
|
+ BUG_ON(RB_EMPTY_ROOT(&cfqq->sort_list));
|
|
|
|
+
|
|
|
|
+ if (!cfq_may_dispatch(cfqd, cfqq))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * follow expired path, else get first next available
|
|
|
|
+ */
|
|
|
|
+ rq = cfq_check_fifo(cfqq);
|
|
|
|
+ if (!rq)
|
|
|
|
+ rq = cfqq->next_rq;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * insert request into driver dispatch list
|
|
|
|
+ */
|
|
|
|
+ cfq_dispatch_insert(cfqd->queue, rq);
|
|
|
|
+
|
|
|
|
+ if (!cfqd->active_cic) {
|
|
|
|
+ struct cfq_io_cq *cic = RQ_CIC(rq);
|
|
|
|
+
|
|
|
|
+ atomic_long_inc(&cic->icq.ioc->refcount);
|
|
|
|
+ cfqd->active_cic = cic;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Find the cfqq that we need to service and move a request from that to the
|
|
|
|
+ * dispatch list
|
|
|
|
+ */
|
|
|
|
+static int cfq_dispatch_requests(struct request_queue *q, int force)
|
|
|
|
+{
|
|
|
|
+ struct cfq_data *cfqd = q->elevator->elevator_data;
|
|
|
|
+ struct cfq_queue *cfqq;
|
|
|
|
+
|
|
|
|
+ if (!cfqd->busy_queues)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ if (unlikely(force))
|
|
|
|
+ return cfq_forced_dispatch(cfqd);
|
|
|
|
+
|
|
|
|
+ cfqq = cfq_select_queue(cfqd);
|
|
|
|
+ if (!cfqq)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Dispatch a request from this cfqq, if it is allowed
|
|
|
|
+ */
|
|
|
|
+ if (!cfq_dispatch_request(cfqd, cfqq))
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ cfqq->slice_dispatch++;
|
|
|
|
+ cfq_clear_cfqq_must_dispatch(cfqq);
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * expire an async queue immediately if it has used up its slice. idle
|
|
|
|
+ * queue always expire after 1 dispatch round.
|
|
|
|
+ */
|
|
|
|
+ if (cfqd->busy_queues > 1 && ((!cfq_cfqq_sync(cfqq) &&
|