blk-wbt: make enable_state more accurate

Currently, if user disable wbt through sysfs, 'enable_state' will be
'WBT_STATE_ON_MANUAL', which will be confusing. Add a new state
'WBT_STATE_OFF_MANUAL' to cover that case.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20221019121518.3865235-4-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Yu Kuai 2022-10-19 20:15:15 +08:00 committed by Jens Axboe
parent b11d31ae01
commit a9a236d238
2 changed files with 13 additions and 6 deletions

View file

@ -435,8 +435,13 @@ void wbt_set_min_lat(struct request_queue *q, u64 val)
struct rq_qos *rqos = wbt_rq_qos(q); struct rq_qos *rqos = wbt_rq_qos(q);
if (!rqos) if (!rqos)
return; return;
RQWB(rqos)->min_lat_nsec = val; RQWB(rqos)->min_lat_nsec = val;
RQWB(rqos)->enable_state = WBT_STATE_ON_MANUAL; if (val)
RQWB(rqos)->enable_state = WBT_STATE_ON_MANUAL;
else
RQWB(rqos)->enable_state = WBT_STATE_OFF_MANUAL;
wbt_update_limits(RQWB(rqos)); wbt_update_limits(RQWB(rqos));
} }

View file

@ -28,13 +28,15 @@ enum {
}; };
/* /*
* Enable states. Either off, or on by default (done at init time), * If current state is WBT_STATE_ON/OFF_DEFAULT, it can be covered to any other
* or on through manual setup in sysfs. * state, if current state is WBT_STATE_ON/OFF_MANUAL, it can only be covered
* to WBT_STATE_OFF/ON_MANUAL.
*/ */
enum { enum {
WBT_STATE_ON_DEFAULT = 1, WBT_STATE_ON_DEFAULT = 1, /* on by default */
WBT_STATE_ON_MANUAL = 2, WBT_STATE_ON_MANUAL = 2, /* on manually by sysfs */
WBT_STATE_OFF_DEFAULT WBT_STATE_OFF_DEFAULT = 3, /* off by default */
WBT_STATE_OFF_MANUAL = 4, /* off manually by sysfs */
}; };
struct rq_wb { struct rq_wb {