Skip to content

Commit 5aceaeb

Browse files
Christoph Hellwigaxboe
authored andcommitted
blk-mq: only dispatch to non-defauly queue maps if they have queues
We should check if a given queue map actually has queues enabled before dispatching to it. This allows drivers to not initialize optional but not used map types, which subsequently will allow fixing problems with queue map rebuilds for that case. Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 346fc10 commit 5aceaeb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

block/blk-mq.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,17 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
105105
{
106106
enum hctx_type type = HCTX_TYPE_DEFAULT;
107107

108-
if (q->tag_set->nr_maps > HCTX_TYPE_POLL &&
109-
((flags & REQ_HIPRI) && test_bit(QUEUE_FLAG_POLL, &q->queue_flags)))
108+
if ((flags & REQ_HIPRI) &&
109+
q->tag_set->nr_maps > HCTX_TYPE_POLL &&
110+
q->tag_set->map[HCTX_TYPE_POLL].nr_queues &&
111+
test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
110112
type = HCTX_TYPE_POLL;
111113

112-
else if (q->tag_set->nr_maps > HCTX_TYPE_READ &&
113-
((flags & REQ_OP_MASK) == REQ_OP_READ))
114+
else if (((flags & REQ_OP_MASK) == REQ_OP_READ) &&
115+
q->tag_set->nr_maps > HCTX_TYPE_READ &&
116+
q->tag_set->map[HCTX_TYPE_READ].nr_queues)
114117
type = HCTX_TYPE_READ;
115-
118+
116119
return blk_mq_map_queue_type(q, type, cpu);
117120
}
118121

0 commit comments

Comments
 (0)