Re: [PATCH] blk-wbt: Always change enable_state to MANUAL when setting latency
From: yu kuai
Date: Fri Jul 24 2026 - 02:52:18 EST
在 2026/7/17 20:50, Tang Yizhou 写道:
> From: Tang Yizhou<yizhou.tang@xxxxxxxxxx>
>
> Commit 1e56f30a73f3 ("block: Make WBT latency writes honor enable
> state") compares only the boolean enabled state in the no-op check.
> Writing the current latency value while WBT is in WBT_STATE_ON_DEFAULT
> is therefore still skipped, and enable_state is not changed to
> WBT_STATE_ON_MANUAL. A subsequent elevator switch to BFQ then disables
> WBT through wbt_disable_default(), silently discarding the explicit
> sysfs setting:
>
> # enable_state = WBT_STATE_ON_DEFAULT, min_lat_nsec = 2000000
> echo 2000 > /sys/block/nullb0/queue/wbt_lat_usec # skipped as a no-op
> echo bfq > /sys/block/nullb0/queue/scheduler
> cat /sys/block/nullb0/queue/wbt_lat_usec # 0, WBT disabled
>
> Skip the update only if the stored latency matches and enable_state
> already equals the exact target state: WBT_STATE_ON_MANUAL for a
> non-zero value, WBT_STATE_OFF_MANUAL for zero.
>
> A write that passes the check then reaches wbt_set_min_lat(), which
> performs the actual transition to the MANUAL state.
>
> Rename the helper to wbt_lat_changed() to improve readability.
>
> Fixes: 1e56f30a73f3 ("block: Make WBT latency writes honor enable state")
> Signed-off-by: Tang Yizhou<yizhou.tang@xxxxxxxxxx>
> ---
> block/blk-wbt.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
Reviewed-by: Yu Kuai <yukuai@xxxxxxx>
--
Thanks,
Kuai