linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3] block: drain queue before waiting for q_usage_counter becoming zero
@ 2017-11-29 23:56 Ming Lei
  2017-12-20 23:12 ` Ming Lei
  2018-01-05 16:10 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2017-11-29 23:56 UTC (permalink / raw)
  To: Jens Axboe, linux-block, Christoph Hellwig
  Cc: Omar Sandoval, Bart Van Assche, Hannes Reinecke, chenxiang,
	Mauricio Faria de Oliveira, Ming Lei, Wen Xiong

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.

Link: https://marc.info/?l=linux-block&m=151192424731797&w=2
Fixes: 055f6e18e08f("block: Make q_usage_counter also track legacy requests")
Cc: Wen Xiong <wenxiong@us.ibm.com>
Tested-by: "chenxiang (M)" <chenxiang66@hisilicon.com>
Tested-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
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(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index e5a623b45a1d..01329367e51c 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -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);
 
diff --git a/block/blk-mq.c b/block/blk-mq.c
index c94a8d225b63..e4c2e5c17343 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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);
 }
 
diff --git a/block/blk.h b/block/blk.h
index 3f1446937aec..442098aa9463 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -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 */
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] block: drain queue before waiting for q_usage_counter becoming zero
  2017-11-29 23:56 [PATCH V3] block: drain queue before waiting for q_usage_counter becoming zero Ming Lei
@ 2017-12-20 23:12 ` Ming Lei
  2018-01-05 16:10 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Ming Lei @ 2017-12-20 23:12 UTC (permalink / raw)
  To: Jens Axboe, linux-block, Christoph Hellwig
  Cc: Omar Sandoval, Bart Van Assche, Hannes Reinecke, chenxiang,
	Mauricio Faria de Oliveira, Wen Xiong

On Thu, Nov 30, 2017 at 07:56:35AM +0800, Ming Lei wrote:
> 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.
> 
> Link: https://marc.info/?l=linux-block&m=151192424731797&w=2
> Fixes: 055f6e18e08f("block: Make q_usage_counter also track legacy requests")
> Cc: Wen Xiong <wenxiong@us.ibm.com>
> Tested-by: "chenxiang (M)" <chenxiang66@hisilicon.com>
> Tested-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> V3:
> 	- V2 can't cover chenxiang's issue, so we have to drain queue via
> 	blk_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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] block: drain queue before waiting for q_usage_counter becoming zero
  2017-11-29 23:56 [PATCH V3] block: drain queue before waiting for q_usage_counter becoming zero Ming Lei
  2017-12-20 23:12 ` Ming Lei
@ 2018-01-05 16:10 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-01-05 16:10 UTC (permalink / raw)
  To: Ming Lei, linux-block, Christoph Hellwig
  Cc: Omar Sandoval, Bart Van Assche, Hannes Reinecke, chenxiang,
	Mauricio Faria de Oliveira, Wen Xiong

On 11/29/17 4:56 PM, Ming Lei wrote:
> 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.

Better late than never, added for 4.15, thanks Ming.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-05 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-29 23:56 [PATCH V3] block: drain queue before waiting for q_usage_counter becoming zero Ming Lei
2017-12-20 23:12 ` Ming Lei
2018-01-05 16:10 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).