diff options
author | Ming Lei <ming.lei@redhat.com> | 2019-08-27 07:01:46 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-08-27 12:40:20 -0400 |
commit | c6ba933358f0d7a6a042b894dba20cc70396a6d3 (patch) | |
tree | e5d7c3e7fadb316f744edc706a3b8df14a4157aa /block | |
parent | c48dac137a62a5d6fa1ef3fa445cbd9c43655a76 (diff) |
blk-mq: don't hold q->sysfs_lock in blk_mq_map_swqueue
blk_mq_map_swqueue() is called from blk_mq_init_allocated_queue()
and blk_mq_update_nr_hw_queues(). For the former caller, the kobject
isn't exposed to userspace yet. For the latter caller, hctx sysfs entries
and debugfs are un-registered before updating nr_hw_queues.
On the other hand, commit 2f8f1336a48b ("blk-mq: always free hctx after
request queue is freed") moves freeing hctx into queue's release
handler, so there won't be race with queue release path too.
So don't hold q->sysfs_lock in blk_mq_map_swqueue().
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
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.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index 509f69fdfcf2..cf768d0c2950 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -2456,11 +2456,6 @@ static void blk_mq_map_swqueue(struct request_queue *q) | |||
2456 | struct blk_mq_ctx *ctx; | 2456 | struct blk_mq_ctx *ctx; |
2457 | struct blk_mq_tag_set *set = q->tag_set; | 2457 | struct blk_mq_tag_set *set = q->tag_set; |
2458 | 2458 | ||
2459 | /* | ||
2460 | * Avoid others reading imcomplete hctx->cpumask through sysfs | ||
2461 | */ | ||
2462 | mutex_lock(&q->sysfs_lock); | ||
2463 | |||
2464 | queue_for_each_hw_ctx(q, hctx, i) { | 2459 | queue_for_each_hw_ctx(q, hctx, i) { |
2465 | cpumask_clear(hctx->cpumask); | 2460 | cpumask_clear(hctx->cpumask); |
2466 | hctx->nr_ctx = 0; | 2461 | hctx->nr_ctx = 0; |
@@ -2521,8 +2516,6 @@ static void blk_mq_map_swqueue(struct request_queue *q) | |||
2521 | HCTX_TYPE_DEFAULT, i); | 2516 | HCTX_TYPE_DEFAULT, i); |
2522 | } | 2517 | } |
2523 | 2518 | ||
2524 | mutex_unlock(&q->sysfs_lock); | ||
2525 | |||
2526 | queue_for_each_hw_ctx(q, hctx, i) { | 2519 | queue_for_each_hw_ctx(q, hctx, i) { |
2527 | /* | 2520 | /* |
2528 | * If no software queues are mapped to this hardware queue, | 2521 | * If no software queues are mapped to this hardware queue, |