Skip to content

Commit

Permalink
block: avoid to quiesce queue in elevator_init_mq
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Damien Le Moal <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Ming Lei authored and axboe committed Nov 17, 2021
1 parent d1faacb commit 245a489
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,18 @@ void elevator_init_mq(struct request_queue *q)
if (!e)
return;

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

err = blk_mq_init_sched(q, e);

blk_mq_unquiesce_queue(q);
blk_mq_unfreeze_queue(q);

if (err) {
Expand Down

0 comments on commit 245a489

Please sign in to comment.