]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
blk-mq: avoid setting hctx->tags->cpumask before allocation
authorAkinobu Mita <akinobu.mita@gmail.com>
Sat, 26 Sep 2015 17:09:19 +0000 (02:09 +0900)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 17 Aug 2016 22:15:03 +0000 (15:15 -0700)
Orabug: 24465370,24464170,24300199

When unmapped hw queue is remapped after CPU topology is changed,
hctx->tags->cpumask has to be set after hctx->tags is setup in
blk_mq_map_swqueue(), otherwise it causes null pointer dereference.

Fixes: f26cdc8536 ("blk-mq: Shared tag enhancements")
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 1356aae08338f1c19ce1c67bf8c543a267688fc3)
Signed-off-by: Bob Liu <bob.liu@oracle.com>
block/blk-mq.c

index 7684b13fd4af2912537c55019b70e54c9ec2dc1a..b88e59e4d80584e85bfbf2ab08986c0458ce7aed 100644 (file)
@@ -1754,7 +1754,6 @@ static void blk_mq_map_swqueue(struct request_queue *q,
                hctx = q->mq_ops->map_queue(q, i);
 
                cpumask_set_cpu(i, hctx->cpumask);
-               cpumask_set_cpu(i, hctx->tags->cpumask);
                ctx->index_hw = hctx->nr_ctx;
                hctx->ctxs[hctx->nr_ctx++] = ctx;
        }
@@ -1794,6 +1793,14 @@ static void blk_mq_map_swqueue(struct request_queue *q,
                hctx->next_cpu = cpumask_first(hctx->cpumask);
                hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH;
        }
+
+       queue_for_each_ctx(q, ctx, i) {
+               if (!cpu_online(i))
+                       continue;
+
+               hctx = q->mq_ops->map_queue(q, i);
+               cpumask_set_cpu(i, hctx->tags->cpumask);
+       }
 }
 
 static void queue_set_hctx_shared(struct request_queue *q, bool shared)