Commit 8a2b20a9 authored by Yu Kuai's avatar Yu Kuai Committed by Jens Axboe

blk-wbt: fix that wbt can't be disabled by default

commit b11d31ae ("blk-wbt: remove unnecessary check in
wbt_enable_default()") removes the checking of CONFIG_BLK_WBT_MQ by
mistake, which is used to control enable or disable wbt by default.

Fix the problem by adding back the checking. This patch also do a litter
cleanup to make related code more readable.

Fixes: b11d31ae ("blk-wbt: remove unnecessary check in wbt_enable_default()")
Reported-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/lkml/CAKXUXMzfKq_J9nKHGyr5P5rvUETY4B-fxoQD4sO+NYjFOfVtZA@mail.gmail.com/t/Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230522121854.2928880-1-yukuai1@huaweicloud.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e3afec91
...@@ -730,14 +730,16 @@ void wbt_enable_default(struct gendisk *disk) ...@@ -730,14 +730,16 @@ void wbt_enable_default(struct gendisk *disk)
{ {
struct request_queue *q = disk->queue; struct request_queue *q = disk->queue;
struct rq_qos *rqos; struct rq_qos *rqos;
bool disable_flag = q->elevator && bool enable = IS_ENABLED(CONFIG_BLK_WBT_MQ);
test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags);
if (q->elevator &&
test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags))
enable = false;
/* Throttling already enabled? */ /* Throttling already enabled? */
rqos = wbt_rq_qos(q); rqos = wbt_rq_qos(q);
if (rqos) { if (rqos) {
if (!disable_flag && if (enable && RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT; RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT;
return; return;
} }
...@@ -746,7 +748,7 @@ void wbt_enable_default(struct gendisk *disk) ...@@ -746,7 +748,7 @@ void wbt_enable_default(struct gendisk *disk)
if (!blk_queue_registered(q)) if (!blk_queue_registered(q))
return; return;
if (queue_is_mq(q) && !disable_flag) if (queue_is_mq(q) && enable)
wbt_init(disk); wbt_init(disk);
} }
EXPORT_SYMBOL_GPL(wbt_enable_default); EXPORT_SYMBOL_GPL(wbt_enable_default);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment