[PATCH 4/4] block: cancel all throttled bios in blk_cleanup_queue()

From: Yu Kuai
Date: Wed Sep 22 2021 - 08:41:54 EST


Throttled bios can't be issued after queue is dying in
blk_cleanup_queue(), thus it's better to cancel them immediately
rather than waiting for throttle is done.

For example, if user thread is throttled with low bps while is
issuing large io, and the device is deleted. The user thread will
wait for a long time for io to return.

Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
block/blk-core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/block/blk-core.c b/block/blk-core.c
index 5454db2fa263..356a56318068 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -389,6 +389,9 @@ void blk_cleanup_queue(struct request_queue *q)

blk_queue_flag_set(QUEUE_FLAG_DEAD, q);

+ if (q->root_blkg)
+ blk_throtl_cancel_bios(q);
+
/* for synchronous bio-based driver finish in-flight integrity i/o */
blk_flush_integrity();

--
2.31.1