block: move ELEVATOR_FLAG_DISABLE_WBT a request queue flag
authorMing Lei <ming.lei@redhat.com>
Mon, 5 May 2025 14:17:40 +0000 (22:17 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 6 May 2025 13:43:42 +0000 (07:43 -0600)
ELEVATOR_FLAG_DISABLE_WBT is only used by BFQ to disallow wbt when BFQ is
in use. The flag is set in BFQ's init(), and cleared in BFQ's exit().

Making it as request queue flag, so that we can avoid to deal with elevator
switch race. Also it isn't graceful to checking one scheduler flag in
wbt_enable_default().

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250505141805.2751237-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bfq-iosched.c
block/blk-mq-debugfs.c
block/blk-wbt.c
block/elevator.h
include/linux/blkdev.h

index abd80dc135623a0ab236719c5b98905993927520..cc6f59836dcd2b40635935f32b87cee57e62a7d0 100644 (file)
@@ -7210,7 +7210,7 @@ static void bfq_exit_queue(struct elevator_queue *e)
 #endif
 
        blk_stat_disable_accounting(bfqd->queue);
-       clear_bit(ELEVATOR_FLAG_DISABLE_WBT, &e->flags);
+       blk_queue_flag_clear(QUEUE_FLAG_DISABLE_WBT_DEF, bfqd->queue);
        wbt_enable_default(bfqd->queue->disk);
 
        kfree(bfqd);
@@ -7397,7 +7397,7 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
        /* We dispatch from request queue wide instead of hw queue */
        blk_queue_flag_set(QUEUE_FLAG_SQ_SCHED, q);
 
-       set_bit(ELEVATOR_FLAG_DISABLE_WBT, &eq->flags);
+       blk_queue_flag_set(QUEUE_FLAG_DISABLE_WBT_DEF, q);
        wbt_disable_default(q->disk);
        blk_stat_enable_accounting(q);
 
index 3421b5521fe287be94010d7680a5c4ad72c7a296..7710c409e4329cc2ef30bb6b739f8241f6e55e46 100644 (file)
@@ -93,6 +93,7 @@ static const char *const blk_queue_flag_name[] = {
        QUEUE_FLAG_NAME(RQ_ALLOC_TIME),
        QUEUE_FLAG_NAME(HCTX_ACTIVE),
        QUEUE_FLAG_NAME(SQ_SCHED),
+       QUEUE_FLAG_NAME(DISABLE_WBT_DEF),
 };
 #undef QUEUE_FLAG_NAME
 
index f1754d07f7e0e147ed5f8a15bd290f96dac1d46c..29cd2e33666fec9e871ce3dde549a64f7de042ff 100644 (file)
@@ -704,8 +704,7 @@ void wbt_enable_default(struct gendisk *disk)
        struct rq_qos *rqos;
        bool enable = IS_ENABLED(CONFIG_BLK_WBT_MQ);
 
-       if (q->elevator &&
-           test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags))
+       if (blk_queue_disable_wbt(q))
                enable = false;
 
        /* Throttling already enabled? */
index e4e44dfac50344ef3cbb65405f86b763490a743e..e27af5492cdbb237265385e5e8dcdbb672b8b988 100644 (file)
@@ -121,7 +121,6 @@ struct elevator_queue
 };
 
 #define ELEVATOR_FLAG_REGISTERED       0
-#define ELEVATOR_FLAG_DISABLE_WBT      1
 
 /*
  * block elevator interface
index 5ccb961ee2ae7bbc5a577c1e048244753bf34abc..c36d7a1c2cc06e432f1b705b4790bec4bff87d7e 100644 (file)
@@ -641,6 +641,7 @@ enum {
        QUEUE_FLAG_RQ_ALLOC_TIME,       /* record rq->alloc_time_ns */
        QUEUE_FLAG_HCTX_ACTIVE,         /* at least one blk-mq hctx is active */
        QUEUE_FLAG_SQ_SCHED,            /* single queue style io dispatch */
+       QUEUE_FLAG_DISABLE_WBT_DEF,     /* for sched to disable/enable wbt */
        QUEUE_FLAG_MAX
 };
 
@@ -676,6 +677,8 @@ void blk_queue_flag_clear(unsigned int flag, struct request_queue *q);
 #define blk_queue_sq_sched(q)  test_bit(QUEUE_FLAG_SQ_SCHED, &(q)->queue_flags)
 #define blk_queue_skip_tagset_quiesce(q) \
        ((q)->limits.features & BLK_FEAT_SKIP_TAGSET_QUIESCE)
+#define blk_queue_disable_wbt(q)       \
+       test_bit(QUEUE_FLAG_DISABLE_WBT_DEF, &(q)->queue_flags)
 
 extern void blk_set_pm_only(struct request_queue *q);
 extern void blk_clear_pm_only(struct request_queue *q);