Skip to content

Commit 245a489

Browse files
Ming Leiaxboe
authored andcommitted
block: avoid to quiesce queue in elevator_init_mq
elevator_init_mq() is only called before adding disk, when there isn't any FS I/O, only passthrough requests can be queued, so freezing queue plus canceling dispatch work is enough to drain any dispatch activities, then we can avoid synchronize_srcu() in blk_mq_quiesce_queue(). Long boot latency issue can be fixed in case of lots of disks added during booting. Fixes: 737eb78 ("block: Delay default elevator initialization") Reported-by: yangerkun <yangerkun@huawei.com> Cc: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20211117115502.1600950-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d1faacb commit 245a489

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

block/elevator.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,12 +694,18 @@ void elevator_init_mq(struct request_queue *q)
694694
if (!e)
695695
return;
696696

697+
/*
698+
* We are called before adding disk, when there isn't any FS I/O,
699+
* so freezing queue plus canceling dispatch work is enough to
700+
* drain any dispatch activities originated from passthrough
701+
* requests, then no need to quiesce queue which may add long boot
702+
* latency, especially when lots of disks are involved.
703+
*/
697704
blk_mq_freeze_queue(q);
698-
blk_mq_quiesce_queue(q);
705+
blk_mq_cancel_work_sync(q);
699706

700707
err = blk_mq_init_sched(q, e);
701708

702-
blk_mq_unquiesce_queue(q);
703709
blk_mq_unfreeze_queue(q);
704710

705711
if (err) {

0 commit comments

Comments
 (0)