Skip to content

Commit b520f00

Browse files
Ming Leigregkh
authored andcommitted
blk-mq: avoid to synchronize rcu inside blk_cleanup_queue()
[ Upstream commit 1311326 ] SCSI probing may synchronously create and destroy a lot of request_queues for non-existent devices. Any synchronize_rcu() in queue creation or destroy path may introduce long latency during booting, see detailed description in comment of blk_register_queue(). This patch removes one synchronize_rcu() inside blk_cleanup_queue() for this case, commit c2856ae(blk-mq: quiesce queue before freeing queue) needs synchronize_rcu() for implementing blk_mq_quiesce_queue(), but when queue isn't initialized, it isn't necessary to do that since only pass-through requests are involved, no original issue in scsi_execute() at all. Without this patch and previous one, it may take more 20+ seconds for virtio-scsi to complete disk probe. With the two patches, the time becomes less than 100ms. Fixes: c2856ae ("blk-mq: quiesce queue before freeing queue") Reported-by: Andrew Jones <[email protected]> Cc: Omar Sandoval <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: [email protected] Cc: "Martin K. Petersen" <[email protected]> Cc: Christoph Hellwig <[email protected]> Tested-by: Andrew Jones <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 07a252b commit b520f00

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

block/blk-core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,13 @@ void blk_cleanup_queue(struct request_queue *q)
669669
* make sure all in-progress dispatch are completed because
670670
* blk_freeze_queue() can only complete all requests, and
671671
* dispatch may still be in-progress since we dispatch requests
672-
* from more than one contexts
672+
* from more than one contexts.
673+
*
674+
* No need to quiesce queue if it isn't initialized yet since
675+
* blk_freeze_queue() should be enough for cases of passthrough
676+
* request.
673677
*/
674-
if (q->mq_ops)
678+
if (q->mq_ops && blk_queue_init_done(q))
675679
blk_mq_quiesce_queue(q);
676680

677681
/* for synchronous bio-based driver finish in-flight integrity i/o */

0 commit comments

Comments
 (0)