Skip to contentSkip to conversation

block: avoid to quiesce queue in elevator_init_mq

PATCH Applied Ming Lei 2 participants 2 messages Nov 17, 2021 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 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 737eb78e82d5 ("block: Delay default elevator initialization")
Cc Damien Le Moal <[email protected]>
---
 block/elevator.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
block/elevator.c +8 -2
index 1f39f6e8ebb9..19a78d5516ba 100644
@@ -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) {
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 9 lines · Ming Lei

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.

[...]

Applied, thanks!

[1/1] block: avoid to quiesce queue in elevator_init_mq

      commit: 245a489e81e13dd55ae46d27becf6d5901eb7828

Best regards,

Signature · 1 line
Jens Axboe