Skip to content

Commit 058fdec

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: fix in-service-queue check for queue merging
When a new I/O request arrives for a bfq_queue, say Q, bfq checks whether that request is close to (a) the head request of some other queue waiting to be served, or (b) the last request dispatched for the in-service queue (in case Q itself is not the in-service queue) If a queue, say Q2, is found for which the above condition holds, then bfq merges Q and Q2, to hopefully get a more sequential I/O in the resulting merged queue, and thus a possibly higher throughput. Case (b) is checked by comparing the new request for Q with the last request dispatched, assuming that the latter necessarily belonged to the in-service queue. Unfortunately, this assumption is no longer always correct, since commit d0edc24 ("block, bfq: inject other-queue I/O into seeky idle queues on NCQ flash"). When the assumption does not hold, queues that must not be merged may be merged, causing unexpected loss of control on per-queue service guarantees. This commit solves this problem by adding an extra field, which stores the actual last request dispatched for the in-service queue, and by using this new field to correctly check case (b). Signed-off-by: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 02a6d78 commit 058fdec

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎block/bfq-iosched.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,8 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
22512251

22522252
if (in_service_bfqq && in_service_bfqq != bfqq &&
22532253
likely(in_service_bfqq != &bfqd->oom_bfqq) &&
2254-
bfq_rq_close_to_sector(io_struct, request, bfqd->last_position) &&
2254+
bfq_rq_close_to_sector(io_struct, request,
2255+
bfqd->in_serv_last_pos) &&
22552256
bfqq->entity.parent == in_service_bfqq->entity.parent &&
22562257
bfq_may_be_close_cooperator(bfqq, in_service_bfqq)) {
22572258
new_bfqq = bfq_setup_merge(bfqq, in_service_bfqq);
@@ -2791,6 +2792,8 @@ static void bfq_update_peak_rate(struct bfq_data *bfqd, struct request *rq)
27912792
bfq_update_rate_reset(bfqd, rq);
27922793
update_last_values:
27932794
bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq);
2795+
if (RQ_BFQQ(rq) == bfqd->in_service_queue)
2796+
bfqd->in_serv_last_pos = bfqd->last_position;
27942797
bfqd->last_dispatch = now_ns;
27952798
}
27962799

‎block/bfq-iosched.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,9 @@ struct bfq_data {
538538
/* on-disk position of the last served request */
539539
sector_t last_position;
540540

541+
/* position of the last served request for the in-service queue */
542+
sector_t in_serv_last_pos;
543+
541544
/* time of last request completion (ns) */
542545
u64 last_completion;
543546

0 commit comments

Comments
 (0)