Skip to content

Commit

Permalink
block: Catch possible entries missing from alloc_policy_name[]
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
John Garry authored and Jens Axboe committed Jul 19, 2024
1 parent 226f0f6 commit 26d3bdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions block/blk-mq-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
8 changes: 6 additions & 2 deletions include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 26d3bdb

Please sign in to comment.