aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2018-04-24 16:01:44 -0400
committerJens Axboe <axboe@kernel.dk>2018-04-25 11:49:22 -0400
commit4412efecf7fda3b8f9f18feed7938f2281f5ccbc (patch)
tree911c447444e015012fa54ea15915f530f6bcef39 /block
parentfe644072dfee069d97a66ea9a80f4bc461499e6a (diff)
Revert "blk-mq: remove code for dealing with remapping queue"
This reverts commit 37c7c6c76d431dd7ef9c29d95f6052bd425f004c. Turns out some drivers(most are FC drivers) may not use managed IRQ affinity, and has their customized .map_queues meantime, so still keep this code for avoiding regression. Reported-by: Laurence Oberman <loberman@redhat.com> Tested-by: Laurence Oberman <loberman@redhat.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Stefan Haberland <sth@linux.vnet.ibm.com> Cc: Ewan Milne <emilne@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-mq.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e4aa36817367..c3621453ad87 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2336,7 +2336,7 @@ static void blk_mq_free_map_and_requests(struct blk_mq_tag_set *set,
2336 2336
2337static void blk_mq_map_swqueue(struct request_queue *q) 2337static void blk_mq_map_swqueue(struct request_queue *q)
2338{ 2338{
2339 unsigned int i; 2339 unsigned int i, hctx_idx;
2340 struct blk_mq_hw_ctx *hctx; 2340 struct blk_mq_hw_ctx *hctx;
2341 struct blk_mq_ctx *ctx; 2341 struct blk_mq_ctx *ctx;
2342 struct blk_mq_tag_set *set = q->tag_set; 2342 struct blk_mq_tag_set *set = q->tag_set;
@@ -2353,8 +2353,23 @@ static void blk_mq_map_swqueue(struct request_queue *q)
2353 2353
2354 /* 2354 /*
2355 * Map software to hardware queues. 2355 * Map software to hardware queues.
2356 *
2357 * If the cpu isn't present, the cpu is mapped to first hctx.
2356 */ 2358 */
2357 for_each_possible_cpu(i) { 2359 for_each_possible_cpu(i) {
2360 hctx_idx = q->mq_map[i];
2361 /* unmapped hw queue can be remapped after CPU topo changed */
2362 if (!set->tags[hctx_idx] &&
2363 !__blk_mq_alloc_rq_map(set, hctx_idx)) {
2364 /*
2365 * If tags initialization fail for some hctx,
2366 * that hctx won't be brought online. In this
2367 * case, remap the current ctx to hctx[0] which
2368 * is guaranteed to always have tags allocated
2369 */
2370 q->mq_map[i] = 0;
2371 }
2372
2358 ctx = per_cpu_ptr(q->queue_ctx, i); 2373 ctx = per_cpu_ptr(q->queue_ctx, i);
2359 hctx = blk_mq_map_queue(q, i); 2374 hctx = blk_mq_map_queue(q, i);
2360 2375
@@ -2366,8 +2381,21 @@ static void blk_mq_map_swqueue(struct request_queue *q)
2366 mutex_unlock(&q->sysfs_lock); 2381 mutex_unlock(&q->sysfs_lock);
2367 2382
2368 queue_for_each_hw_ctx(q, hctx, i) { 2383 queue_for_each_hw_ctx(q, hctx, i) {
2369 /* every hctx should get mapped by at least one CPU */ 2384 /*
2370 WARN_ON(!hctx->nr_ctx); 2385 * If no software queues are mapped to this hardware queue,
2386 * disable it and free the request entries.
2387 */
2388 if (!hctx->nr_ctx) {
2389 /* Never unmap queue 0. We need it as a
2390 * fallback in case of a new remap fails
2391 * allocation
2392 */
2393 if (i && set->tags[i])
2394 blk_mq_free_map_and_requests(set, i);
2395
2396 hctx->tags = NULL;
2397 continue;
2398 }
2371 2399
2372 hctx->tags = set->tags[i]; 2400 hctx->tags = set->tags[i];
2373 WARN_ON(!hctx->tags); 2401 WARN_ON(!hctx->tags);