block: drain queue before waiting for q_usage_counter becoming zero
PATCH v3 1/1 block: drain queue before waiting for q_usage_counter becoming zero
Now we track legacy requests with .q_usage_counter in commit 055f6e18e08f ("block: Make q_usage_counter also track legacy requests"), but that commit never runs and drains legacy queue before waiting for this counter becoming zero, then IO hang is caused in the test of pulling disk during IO.
This patch fixes the issue by draining requests before waiting for q_usage_counter becoming zero, both Mauricio and chenxiang reported this issue, and observed that it can be fixed by this patch.
---
V3:
- V2 can't cover chenxiang's issue, so we have to drain queue via blk_drain_queue(), and fallback to original post(V1)
block/blk-core.c | 9 +++++++-- block/blk-mq.c | 2 ++ block/blk.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-)
block/blk-core.c +7 -2
@@ -562,6 +562,13 @@ static void __blk_drain_queue(struct request_queue *q, bool drain_all) } } +void blk_drain_queue (struct request_queue *q) +{ +spin_lock_irq (q->queue_lock); +__blk_drain_queue (q, true); +spin_unlock_irq (q->queue_lock); +} +/** * blk_queue_bypass_start - enter queue bypass mode * @q: queue of interest
@@ -689,8 +696,6 @@ void blk_cleanup_queue(struct request_queue *q)*/ blk_freeze_queue (q);spin_lock_irq (lock); -if (!q->mq_ops) -__blk_drain_queue (q, true);queue_flag_set (QUEUE_FLAG_DEAD , q);spin_unlock_irq (lock);
block/blk-mq.c +2 -0
@@ -161,6 +161,8 @@ void blk_freeze_queue(struct request_queue *q)* exported to drivers as the only user for unfreeze is blk_mq. */ blk_freeze_queue_start (q); +if (!q->mq_ops) +blk_drain_queue (q);blk_mq_freeze_queue_wait (q); }
block/blk.h +2 -0
@@ -330,4 +330,6 @@ static inline void blk_queue_bounce(struct request_queue *q, struct bio **bio) }#endif /* CONFIG_BOUNCE */ +extern void blk_drain_queue (struct request_queue *q); +#endif /* BLK_INTERNAL_H */
Signature · 1 line
2.9.5
Quoted 15 lines · Ming Lei
Now we track legacy requests with .q_usage_counter in commit
055f6e18e08f("block: Makeq_usage_counteralso track legacy requests"), but that commit never runs and drains legacy queue before waiting for this counter becoming zero, then IO hang is caused in the test of pulling disk during IO.This patch fixes the issue by draining requests before waiting for
q_usage_counterbecoming zero, both Mauricio and chenxiang reported this issue, and observed that it can be fixed by this patch.Fixes 055f6e18e08f("block: Make q_usage_counter also track legacy requests")Cc Wen Xiong <[email protected]>Tested-by "chenxiang (M)" <[email protected]>Signed-off-by Ming Lei <[email protected]>
Quoted 4 lines
---
V3:
- V2 can't cover chenxiang's issue, so we have to drain queue viablk_drain_queue(), and fallback to original post(V1)
Hi Jens,
This patch fixes regression caused by 055f6e18e08f merged to v4.15-rc, could you consider it for v4.15?
Thanks,
Ming
Jens Axboe
maintainerQuoted 8 lines · Ming Lei
Now we track legacy requests with .q_usage_counter in commit
055f6e18e08f("block: Makeq_usage_counteralso track legacy requests"), but that commit never runs and drains legacy queue before waiting for this counter becoming zero, then IO hang is caused in the test of pulling disk during IO.This patch fixes the issue by draining requests before waiting for
q_usage_counterbecoming zero, both Mauricio and chenxiang reported this issue, and observed that it can be fixed by this patch.
Better late than never, added for 4.15, thanks Ming.
Signature · 1 line
Jens Axboe