summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Garry <john.g.garry@oracle.com>2024-07-19 11:29:08 +0000
committerJens Axboe <axboe@kernel.dk>2024-07-19 09:32:49 -0600
commit26d3bdb57ec3fa56eaf8d2e74b5d488e55f43013 (patch)
tree1cbef473c8fdd63b1bdd650191f6efc73ed53618
parent226f0f6afc3e5c8903c6e57e1f6073ad8ad189b5 (diff)
downloadlwn-26d3bdb57ec3fa56eaf8d2e74b5d488e55f43013.tar.gz
lwn-26d3bdb57ec3fa56eaf8d2e74b5d488e55f43013.zip
block: Catch possible entries missing from alloc_policy_name[]
Make BLK_TAG_ALLOC_x an enum and add a "max" entry. Add a BUILD_BUG_ON() call to ensure that we are not missing entries in hctx_flag_name[]. Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20240719112912.3830443-12-john.g.garry@oracle.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-mq-debugfs.c1
-rw-r--r--include/linux/blk-mq.h8
2 files changed, 7 insertions, 2 deletions
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 8618aa07ba2d..312e8a40caad 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -198,6 +198,7 @@ static int hctx_flags_show(void *data, struct seq_file *m)
BUILD_BUG_ON(ARRAY_SIZE(hctx_flag_name) !=
BLK_MQ_F_ALLOC_POLICY_START_BIT);
+ BUILD_BUG_ON(ARRAY_SIZE(alloc_policy_name) != BLK_TAG_ALLOC_MAX);
seq_puts(m, "alloc_policy=");
if (alloc_policy < ARRAY_SIZE(alloc_policy_name) &&
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 27241009c8f9..a64a50a0edf7 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -278,8 +278,12 @@ enum blk_eh_timer_return {
BLK_EH_RESET_TIMER,
};
-#define BLK_TAG_ALLOC_FIFO 0 /* allocate starting from 0 */
-#define BLK_TAG_ALLOC_RR 1 /* allocate starting from last allocated tag */
+/* Keep alloc_policy_name[] in sync with the definitions below */
+enum {
+ BLK_TAG_ALLOC_FIFO, /* allocate starting from 0 */
+ BLK_TAG_ALLOC_RR, /* allocate starting from last allocated tag */
+ BLK_TAG_ALLOC_MAX
+};
/**
* struct blk_mq_hw_ctx - State for a hardware queue facing the hardware