Skip to content

Commit c125311

Browse files
committed
blk-wbt: don't maintain inflight counts if disabled
A previous commit removed the ability to have per-rq flags. We used those flags to maintain inflight counts. Since we don't have those anymore, we have to always maintain inflight counts, even if wbt is disabled. This is clearly suboptimal. Add a queue quiesce around changing the wbt latency settings from sysfs to work around this. With that, we can reliably put the enabled check in our bio_to_wbt_flags(), since we know the WBT_TRACKED flag will be consistent for the lifetime of the request. Fixes: c1c8038 ("block: remove external dependency on wbt_flags") Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c45e6a0 commit c125311

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

block/blk-sysfs.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,26 @@ static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,
453453
else if (val >= 0)
454454
val *= 1000ULL;
455455

456-
wbt_set_min_lat(q, val);
456+
/*
457+
* Ensure that the queue is idled, in case the latency update
458+
* ends up either enabling or disabling wbt completely. We can't
459+
* have IO inflight if that happens.
460+
*/
461+
if (q->mq_ops) {
462+
blk_mq_freeze_queue(q);
463+
blk_mq_quiesce_queue(q);
464+
} else
465+
blk_queue_bypass_start(q);
457466

467+
wbt_set_min_lat(q, val);
458468
wbt_update_limits(q);
469+
470+
if (q->mq_ops) {
471+
blk_mq_unquiesce_queue(q);
472+
blk_mq_unfreeze_queue(q);
473+
} else
474+
blk_queue_bypass_end(q);
475+
459476
return count;
460477
}
461478

block/blk-wbt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ static enum wbt_flags bio_to_wbt_flags(struct rq_wb *rwb, struct bio *bio)
540540
{
541541
enum wbt_flags flags = 0;
542542

543+
if (!rwb_enabled(rwb))
544+
return 0;
545+
543546
if (bio_op(bio) == REQ_OP_READ) {
544547
flags = WBT_READ;
545548
} else if (wbt_should_throttle(rwb, bio)) {

0 commit comments

Comments
 (0)