diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2015-09-26 13:09:19 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-09-29 13:32:43 -0400 |
commit | 1356aae08338f1c19ce1c67bf8c543a267688fc3 (patch) | |
tree | f8ef88a7710600ead9bcf533bd7f34618ee4a9b3 /block | |
parent | bda4e0fb3126aca15586d165b5a15a37edc0a984 (diff) |
blk-mq: avoid setting hctx->tags->cpumask before allocation
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>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-mq.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index f2d67b4047a0..2fd7283ec62b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -1811,7 +1811,6 @@ static void blk_mq_map_swqueue(struct request_queue *q) | |||
1811 | 1811 | ||
1812 | hctx = q->mq_ops->map_queue(q, i); | 1812 | hctx = q->mq_ops->map_queue(q, i); |
1813 | cpumask_set_cpu(i, hctx->cpumask); | 1813 | cpumask_set_cpu(i, hctx->cpumask); |
1814 | cpumask_set_cpu(i, hctx->tags->cpumask); | ||
1815 | ctx->index_hw = hctx->nr_ctx; | 1814 | ctx->index_hw = hctx->nr_ctx; |
1816 | hctx->ctxs[hctx->nr_ctx++] = ctx; | 1815 | hctx->ctxs[hctx->nr_ctx++] = ctx; |
1817 | } | 1816 | } |
@@ -1851,6 +1850,14 @@ static void blk_mq_map_swqueue(struct request_queue *q) | |||
1851 | hctx->next_cpu = cpumask_first(hctx->cpumask); | 1850 | hctx->next_cpu = cpumask_first(hctx->cpumask); |
1852 | hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH; | 1851 | hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH; |
1853 | } | 1852 | } |
1853 | |||
1854 | queue_for_each_ctx(q, ctx, i) { | ||
1855 | if (!cpu_online(i)) | ||
1856 | continue; | ||
1857 | |||
1858 | hctx = q->mq_ops->map_queue(q, i); | ||
1859 | cpumask_set_cpu(i, hctx->tags->cpumask); | ||
1860 | } | ||
1854 | } | 1861 | } |
1855 | 1862 | ||
1856 | static void blk_mq_update_tag_set_depth(struct blk_mq_tag_set *set) | 1863 | static void blk_mq_update_tag_set_depth(struct blk_mq_tag_set *set) |