Skip to content

Commit 06257fd

Browse files
YuKuai-huaweiaxboe
authored andcommitted
blk-wbt: cleanup rwb_enabled() and wbt_disabled()
'wb_normal' will set to 0 if 'min_lat_nsec' is 0, and 'min_lat_nsec' can only be set to 0 through sysfs configuration where 'WBT_STATE_OFF_MANUAL' is set together, in the meantime, they can only be cleared together through sysfs afterwards. Hence 'wb_normal != 0' is the same as 'rwb->enable_state != WBT_STATE_OFF_MANUAL'. The code is redundan, hence replace the checking of 'wb_normal' to 'enable_state' in rwb_enabled() and reuse rwb_enabled() for wbt_disabled(). Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20230527010644.647900-4-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 71b8642 commit 06257fd

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

block/blk-wbt.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ enum {
146146
static inline bool rwb_enabled(struct rq_wb *rwb)
147147
{
148148
return rwb && rwb->enable_state != WBT_STATE_OFF_DEFAULT &&
149-
rwb->wb_normal != 0;
149+
rwb->enable_state != WBT_STATE_OFF_MANUAL;
150150
}
151151

152152
static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
@@ -494,8 +494,7 @@ bool wbt_disabled(struct request_queue *q)
494494
{
495495
struct rq_qos *rqos = wbt_rq_qos(q);
496496

497-
return !rqos || RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT ||
498-
RQWB(rqos)->enable_state == WBT_STATE_OFF_MANUAL;
497+
return !rqos || !rwb_enabled(RQWB(rqos));
499498
}
500499

501500
u64 wbt_get_min_lat(struct request_queue *q)

0 commit comments

Comments
 (0)