Skip to content

Commit 1e56f30

Browse files
guzebing1612-devaxboe
authored andcommitted
block: Make WBT latency writes honor enable state
queue/wbt_lat_usec controls both the stored WBT latency target and the effective WBT enable state. The old no-op check skipped updates whenever the converted latency matched the stored min_lat_nsec. That check ignored whether the current WBT state already matched the state requested by the write. For a queue disabled by default, attempting to enable WBT by writing the default value through sysfs could return success while the enable state was left unchanged. Treat a write as a no-op only when both the stored latency and the effective WBT enabled state already match the converted value. Signed-off-by: Guzebing <guzebing1612@gmail.com> Link: https://patch.msgid.link/20260621014030.1625306-1-guzebing1612@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3dd63db commit 1e56f30

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

block/blk-wbt.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,21 @@ static void wbt_queue_depth_changed(struct rq_qos *rqos)
813813
wbt_update_limits(RQWB(rqos));
814814
}
815815

816+
static bool wbt_set_lat_changed(struct request_queue *q, u64 val)
817+
{
818+
struct rq_qos *rqos = wbt_rq_qos(q);
819+
struct rq_wb *rwb;
820+
821+
if (!rqos)
822+
return true;
823+
824+
rwb = RQWB(rqos);
825+
if (rwb->min_lat_nsec != val)
826+
return true;
827+
828+
return rwb_enabled(rwb) != !!val;
829+
}
830+
816831
static void wbt_exit(struct rq_qos *rqos)
817832
{
818833
struct rq_wb *rwb = RQWB(rqos);
@@ -1005,8 +1020,12 @@ int wbt_set_lat(struct gendisk *disk, s64 val)
10051020
else if (val >= 0)
10061021
val *= 1000ULL;
10071022

1008-
if (wbt_get_min_lat(q) == val)
1023+
mutex_lock(&disk->rqos_state_mutex);
1024+
if (!wbt_set_lat_changed(q, val)) {
1025+
mutex_unlock(&disk->rqos_state_mutex);
10091026
goto out;
1027+
}
1028+
mutex_unlock(&disk->rqos_state_mutex);
10101029

10111030
blk_mq_quiesce_queue(q);
10121031

0 commit comments

Comments
 (0)