cfq-iosched: Fix the incorrect timeslice accounting with forced_dispatch

When CFQ dispatches requests forcefully due to a barrier or changing iosched,
it runs through all cfqq's dispatching requests and then expires each queue.
However, it does not activate a cfqq before flushing its IOs resulting in
using stale values for computing slice_used.
This patch fixes it by calling activate queue before flushing reuqests from
each queue.

This is useful mostly for barrier requests because when the iosched is changing
it really doesnt matter if we have incorrect accounting since we're going to
break down all structures anyway.

We also now expire the current timeslice before moving on with the dispatch
to accurately account slice used for that cfqq.

Signed-off-by: Divyesh Shah<dpshah@google.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

authored by Divyesh Shah and committed by Jens Axboe 3440c49f 02246c41

+6 -3
+6 -3
block/cfq-iosched.c
··· 2205 struct cfq_queue *cfqq; 2206 int dispatched = 0; 2207 2208 - while ((cfqq = cfq_get_next_queue_forced(cfqd)) != NULL) 2209 - dispatched += __cfq_forced_dispatch_cfqq(cfqq); 2210 - 2211 cfq_slice_expired(cfqd, 0); 2212 BUG_ON(cfqd->busy_queues); 2213 2214 cfq_log(cfqd, "forced_dispatch=%d", dispatched);
··· 2205 struct cfq_queue *cfqq; 2206 int dispatched = 0; 2207 2208 + /* Expire the timeslice of the current active queue first */ 2209 cfq_slice_expired(cfqd, 0); 2210 + while ((cfqq = cfq_get_next_queue_forced(cfqd)) != NULL) { 2211 + __cfq_set_active_queue(cfqd, cfqq); 2212 + dispatched += __cfq_forced_dispatch_cfqq(cfqq); 2213 + } 2214 + 2215 BUG_ON(cfqd->busy_queues); 2216 2217 cfq_log(cfqd, "forced_dispatch=%d", dispatched);