bfq-iosched: stop using blkg->stat_bytes and ->stat_ios
[linux-2.6-microblaze.git] / block / bfq-iosched.c
index b33be92..41d2d83 100644 (file)
@@ -2016,7 +2016,7 @@ static void bfq_add_request(struct request *rq)
                     (bfqq->last_serv_time_ns > 0 &&
                      bfqd->rqs_injected && bfqd->rq_in_driver > 0)) &&
                    time_is_before_eq_jiffies(bfqq->decrease_time_jif +
-                                             msecs_to_jiffies(100))) {
+                                             msecs_to_jiffies(10))) {
                        bfqd->last_empty_occupied_ns = ktime_get_ns();
                        /*
                         * Start the state machine for measuring the
@@ -2025,7 +2025,21 @@ static void bfq_add_request(struct request *rq)
                         * be set when rq will be dispatched.
                         */
                        bfqd->wait_dispatch = true;
-                       bfqd->rqs_injected = false;
+                       /*
+                        * If there is no I/O in service in the drive,
+                        * then possible injection occurred before the
+                        * arrival of rq will not affect the total
+                        * service time of rq. So the injection limit
+                        * must not be updated as a function of such
+                        * total service time, unless new injection
+                        * occurs before rq is completed. To have the
+                        * injection limit updated only in the latter
+                        * case, reset rqs_injected here (rqs_injected
+                        * will be set in case injection is performed
+                        * on bfqq before rq is completed).
+                        */
+                       if (bfqd->rq_in_driver == 0)
+                               bfqd->rqs_injected = false;
                }
        }
 
@@ -5450,6 +5464,10 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
        bool idle_timer_disabled = false;
        unsigned int cmd_flags;
 
+#ifdef CONFIG_BFQ_GROUP_IOSCHED
+       if (!cgroup_subsys_on_dfl(io_cgrp_subsys) && rq->bio)
+               bfqg_stats_update_legacy_io(q, rq);
+#endif
        spin_lock_irq(&bfqd->lock);
        if (blk_mq_sched_try_insert_merge(q, rq)) {
                spin_unlock_irq(&bfqd->lock);
@@ -5784,14 +5802,14 @@ static void bfq_update_inject_limit(struct bfq_data *bfqd,
        u64 tot_time_ns = ktime_get_ns() - bfqd->last_empty_occupied_ns;
        unsigned int old_limit = bfqq->inject_limit;
 
-       if (bfqq->last_serv_time_ns > 0) {
+       if (bfqq->last_serv_time_ns > 0 && bfqd->rqs_injected) {
                u64 threshold = (bfqq->last_serv_time_ns * 3)>>1;
 
                if (tot_time_ns >= threshold && old_limit > 0) {
                        bfqq->inject_limit--;
                        bfqq->decrease_time_jif = jiffies;
                } else if (tot_time_ns < threshold &&
-                          old_limit < bfqd->max_rq_in_driver<<1)
+                          old_limit <= bfqd->max_rq_in_driver)
                        bfqq->inject_limit++;
        }
 
@@ -5809,12 +5827,14 @@ static void bfq_update_inject_limit(struct bfq_data *bfqd,
         */
        if ((bfqq->last_serv_time_ns == 0 && bfqd->rq_in_driver == 1) ||
            tot_time_ns < bfqq->last_serv_time_ns) {
+               if (bfqq->last_serv_time_ns == 0) {
+                       /*
+                        * Now we certainly have a base value: make sure we
+                        * start trying injection.
+                        */
+                       bfqq->inject_limit = max_t(unsigned int, 1, old_limit);
+               }
                bfqq->last_serv_time_ns = tot_time_ns;
-               /*
-                * Now we certainly have a base value: make sure we
-                * start trying injection.
-                */
-               bfqq->inject_limit = max_t(unsigned int, 1, old_limit);
        } else if (!bfqd->rqs_injected && bfqd->rq_in_driver == 1)
                /*
                 * No I/O injected and no request still in service in
@@ -5830,6 +5850,7 @@ static void bfq_update_inject_limit(struct bfq_data *bfqd,
 
        /* update complete, not waiting for any request completion any longer */
        bfqd->waited_rq = NULL;
+       bfqd->rqs_injected = false;
 }
 
 /*