]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: Make WBT latency writes honor enable state
authorGuzebing <guzebing1612@gmail.com>
Sun, 21 Jun 2026 01:40:30 +0000 (09:40 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 2 Jul 2026 01:07:20 +0000 (19:07 -0600)
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>
block/blk-wbt.c

index dcc2438ca16dc77508cc722594139fc63dc0f3b2..953d400fd0137baed5f2f32a7dc08869fd39c596 100644 (file)
@@ -813,6 +813,21 @@ static void wbt_queue_depth_changed(struct rq_qos *rqos)
        wbt_update_limits(RQWB(rqos));
 }
 
+static bool wbt_set_lat_changed(struct request_queue *q, u64 val)
+{
+       struct rq_qos *rqos = wbt_rq_qos(q);
+       struct rq_wb *rwb;
+
+       if (!rqos)
+               return true;
+
+       rwb = RQWB(rqos);
+       if (rwb->min_lat_nsec != val)
+               return true;
+
+       return rwb_enabled(rwb) != !!val;
+}
+
 static void wbt_exit(struct rq_qos *rqos)
 {
        struct rq_wb *rwb = RQWB(rqos);
@@ -1005,8 +1020,12 @@ int wbt_set_lat(struct gendisk *disk, s64 val)
        else if (val >= 0)
                val *= 1000ULL;
 
-       if (wbt_get_min_lat(q) == val)
+       mutex_lock(&disk->rqos_state_mutex);
+       if (!wbt_set_lat_changed(q, val)) {
+               mutex_unlock(&disk->rqos_state_mutex);
                goto out;
+       }
+       mutex_unlock(&disk->rqos_state_mutex);
 
        blk_mq_quiesce_queue(q);