Skip to content

Commit 226f0f6

Browse files
johnpgarryaxboe
authored andcommitted
block: Catch possible entries missing from hctx_flag_name[]
Refresh values in BLK_MQ_F_x enum, and then re-arrange members in hctx_flag_name[] to match that enum. Renumber BLK_MQ_F_ALLOC_POLICY_START_BIT to match the value refresh. Add a BUILD_BUG_ON() call to ensure that we are not missing entries in hctx_flag_name[]. Signed-off-by: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 2382731 commit 226f0f6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

block/blk-mq-debugfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ static int hctx_flags_show(void *data, struct seq_file *m)
196196
struct blk_mq_hw_ctx *hctx = data;
197197
const int alloc_policy = BLK_MQ_FLAG_TO_ALLOC_POLICY(hctx->flags);
198198

199+
BUILD_BUG_ON(ARRAY_SIZE(hctx_flag_name) !=
200+
BLK_MQ_F_ALLOC_POLICY_START_BIT);
201+
199202
seq_puts(m, "alloc_policy=");
200203
if (alloc_policy < ARRAY_SIZE(alloc_policy_name) &&
201204
alloc_policy_name[alloc_policy])

include/linux/blk-mq.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ struct blk_mq_ops {
644644
#endif
645645
};
646646

647+
/* Keep hctx_flag_name[] in sync with the definitions below */
647648
enum {
648649
BLK_MQ_F_SHOULD_MERGE = 1 << 0,
649650
BLK_MQ_F_TAG_QUEUE_SHARED = 1 << 1,
@@ -653,15 +654,16 @@ enum {
653654
*/
654655
BLK_MQ_F_STACKING = 1 << 2,
655656
BLK_MQ_F_TAG_HCTX_SHARED = 1 << 3,
656-
BLK_MQ_F_BLOCKING = 1 << 5,
657+
BLK_MQ_F_BLOCKING = 1 << 4,
657658
/* Do not allow an I/O scheduler to be configured. */
658-
BLK_MQ_F_NO_SCHED = 1 << 6,
659+
BLK_MQ_F_NO_SCHED = 1 << 5,
660+
659661
/*
660662
* Select 'none' during queue registration in case of a single hwq
661663
* or shared hwqs instead of 'mq-deadline'.
662664
*/
663-
BLK_MQ_F_NO_SCHED_BY_DEFAULT = 1 << 7,
664-
BLK_MQ_F_ALLOC_POLICY_START_BIT = 8,
665+
BLK_MQ_F_NO_SCHED_BY_DEFAULT = 1 << 6,
666+
BLK_MQ_F_ALLOC_POLICY_START_BIT = 7,
665667
BLK_MQ_F_ALLOC_POLICY_BITS = 1,
666668
};
667669
#define BLK_MQ_FLAG_TO_ALLOC_POLICY(flags) \

0 commit comments

Comments
 (0)