]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
blk-mq: don't hold q->sysfs_lock in blk_mq_map_swqueue
authorMing Lei <ming.lei@redhat.com>
Tue, 27 Aug 2019 11:01:46 +0000 (19:01 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 27 Aug 2019 16:40:20 +0000 (10:40 -0600)
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>
block/blk-mq.c

index 509f69fdfcf2a34dd0a6a3e9dc3f282658b311cb..cf768d0c295080664b16b20252724da36e4fa0ed 100644 (file)
@@ -2456,11 +2456,6 @@ static void blk_mq_map_swqueue(struct request_queue *q)
        struct blk_mq_ctx *ctx;
        struct blk_mq_tag_set *set = q->tag_set;
 
-       /*
-        * Avoid others reading imcomplete hctx->cpumask through sysfs
-        */
-       mutex_lock(&q->sysfs_lock);
-
        queue_for_each_hw_ctx(q, hctx, i) {
                cpumask_clear(hctx->cpumask);
                hctx->nr_ctx = 0;
@@ -2521,8 +2516,6 @@ static void blk_mq_map_swqueue(struct request_queue *q)
                                        HCTX_TYPE_DEFAULT, i);
        }
 
-       mutex_unlock(&q->sysfs_lock);
-
        queue_for_each_hw_ctx(q, hctx, i) {
                /*
                 * If no software queues are mapped to this hardware queue,