block, bfq: make sure queue budgets are not below service received
authorPaolo Valente <paolo.valente@linaro.org>
Tue, 29 Jan 2019 11:06:27 +0000 (12:06 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 31 Jan 2019 19:50:23 +0000 (12:50 -0700)
With some unlucky sequences of events, the function bfq_updated_next_req
updates the current budget of a bfq_queue to a lower value than the
service received by the queue using such a budget. Unfortunately, if
this happens, then the return value of the function bfq_bfqq_budget_left
becomes inconsistent. This commit solves this problem by lower-bounding
the budget computed in bfq_updated_next_req to the service currently
charged to the queue.

Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bfq-iosched.c

index 9ea2c4f42501f0267bb27779e8d10410d44821d3..b0e8006475be7489161cb101afb181108faea28d 100644 (file)
@@ -907,8 +907,10 @@ static void bfq_updated_next_req(struct bfq_data *bfqd,
                 */
                return;
 
-       new_budget = max_t(unsigned long, bfqq->max_budget,
-                          bfq_serv_to_charge(next_rq, bfqq));
+       new_budget = max_t(unsigned long,
+                          max_t(unsigned long, bfqq->max_budget,
+                                bfq_serv_to_charge(next_rq, bfqq)),
+                          entity->service);
        if (entity->budget != new_budget) {
                entity->budget = new_budget;
                bfq_log_bfqq(bfqd, bfqq, "updated next rq: new budget %lu",