aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/null_blk.c
diff options
context:
space:
mode:
authorMatias Bjorling <m@bjorling.me>2013-12-10 10:50:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-12-15 15:17:16 -0500
commit57053d8c5c59562cac156513740c10b502a40968 (patch)
tree0e71310912a1004760561540bc7e665957468ee5 /drivers/block/null_blk.c
parente4158f1b1090d362a7c998bd654cc3fe8f5c863c (diff)
null_blk: mem garbage on NUMA systems during init
For NUMA systems, initializing the blk-mq layer and using per node hctx. We initialize submit queues to 1, while blk-mq nr_hw_queues is initialized to the number of NUMA nodes. This makes the null_init_hctx function overwrite memory outside of what it allocated. In my case it lead to writing garbage into struct request_queue's mq_map. Signed-off-by: Matias Bjorling <m@bjorling.me> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/null_blk.c')
-rw-r--r--drivers/block/null_blk.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index ea192ec029c4..f370fc13aea5 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -495,23 +495,23 @@ static int null_add_dev(void)
495 495
496 spin_lock_init(&nullb->lock); 496 spin_lock_init(&nullb->lock);
497 497
498 if (queue_mode == NULL_Q_MQ && use_per_node_hctx)
499 submit_queues = nr_online_nodes;
500
498 if (setup_queues(nullb)) 501 if (setup_queues(nullb))
499 goto err; 502 goto err;
500 503
501 if (queue_mode == NULL_Q_MQ) { 504 if (queue_mode == NULL_Q_MQ) {
502 null_mq_reg.numa_node = home_node; 505 null_mq_reg.numa_node = home_node;
503 null_mq_reg.queue_depth = hw_queue_depth; 506 null_mq_reg.queue_depth = hw_queue_depth;
507 null_mq_reg.nr_hw_queues = submit_queues;
504 508
505 if (use_per_node_hctx) { 509 if (use_per_node_hctx) {
506 null_mq_reg.ops->alloc_hctx = null_alloc_hctx; 510 null_mq_reg.ops->alloc_hctx = null_alloc_hctx;
507 null_mq_reg.ops->free_hctx = null_free_hctx; 511 null_mq_reg.ops->free_hctx = null_free_hctx;
508
509 null_mq_reg.nr_hw_queues = nr_online_nodes;
510 } else { 512 } else {
511 null_mq_reg.ops->alloc_hctx = blk_mq_alloc_single_hw_queue; 513 null_mq_reg.ops->alloc_hctx = blk_mq_alloc_single_hw_queue;
512 null_mq_reg.ops->free_hctx = blk_mq_free_single_hw_queue; 514 null_mq_reg.ops->free_hctx = blk_mq_free_single_hw_queue;
513
514 null_mq_reg.nr_hw_queues = submit_queues;
515 } 515 }
516 516
517 nullb->q = blk_mq_init_queue(&null_mq_reg, nullb); 517 nullb->q = blk_mq_init_queue(&null_mq_reg, nullb);