From: Ming Lei Date: Fri, 12 Feb 2016 07:27:00 +0000 (+0800) Subject: blk-mq: mark request queue as mq asap X-Git-Tag: v4.1.12-92~89^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=61330da22e8574967fe602706773387456ea070c;p=users%2Fjedix%2Flinux-maple.git blk-mq: mark request queue as mq asap Orabug: 24454933 Currently q->mq_ops is used widely to decide if the queue is mq or not, so we should set the 'flag' asap so that both block core and drivers can get the correct mq info. For example, commit 868f2f0b720(blk-mq: dynamic h/w context count) moves the hctx's initialization before setting q->mq_ops in blk_mq_init_allocated_queue(), then cause blk_alloc_flush_queue() to think the queue is non-mq and don't allocate command size for the per-hctx flush rq. This patches should fix the problem reported by Sasha. Cc: Keith Busch Reported-by: Sasha Levin Signed-off-by: Ming Lei Fixes: 868f2f0b720 ("blk-mq: dynamic h/w context count") Signed-off-by: Jens Axboe (cherry picked from commit 66841672161efb9e3be4a1dbd9755020bb1d86b7) Signed-off-by: Dan Duval --- diff --git a/block/blk-mq.c b/block/blk-mq.c index b9dd849fcea2..7684b13fd4af 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1958,6 +1958,9 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set, struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, struct request_queue *q) { + /* mark the queue as mq asap */ + q->mq_ops = set->ops; + q->queue_ctx = alloc_percpu(struct blk_mq_ctx); if (!q->queue_ctx) return ERR_PTR(-ENOMEM); @@ -1988,7 +1991,6 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->nr_queues = nr_cpu_ids; - q->mq_ops = set->ops; q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT; if (!(set->flags & BLK_MQ_F_SG_MERGE))