Skip to content

Commit 26d3bdb

Browse files
johnpgarryaxboe
authored andcommitted
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>
1 parent 226f0f6 commit 26d3bdb

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

block/blk-mq-debugfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static int hctx_flags_show(void *data, struct seq_file *m)
198198

199199
BUILD_BUG_ON(ARRAY_SIZE(hctx_flag_name) !=
200200
BLK_MQ_F_ALLOC_POLICY_START_BIT);
201+
BUILD_BUG_ON(ARRAY_SIZE(alloc_policy_name) != BLK_TAG_ALLOC_MAX);
201202

202203
seq_puts(m, "alloc_policy=");
203204
if (alloc_policy < ARRAY_SIZE(alloc_policy_name) &&

include/linux/blk-mq.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,12 @@ enum blk_eh_timer_return {
278278
BLK_EH_RESET_TIMER,
279279
};
280280

281-
#define BLK_TAG_ALLOC_FIFO 0 /* allocate starting from 0 */
282-
#define BLK_TAG_ALLOC_RR 1 /* allocate starting from last allocated tag */
281+
/* Keep alloc_policy_name[] in sync with the definitions below */
282+
enum {
283+
BLK_TAG_ALLOC_FIFO, /* allocate starting from 0 */
284+
BLK_TAG_ALLOC_RR, /* allocate starting from last allocated tag */
285+
BLK_TAG_ALLOC_MAX
286+
};
283287

284288
/**
285289
* struct blk_mq_hw_ctx - State for a hardware queue facing the hardware

0 commit comments

Comments
 (0)