public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-mq: run queue after issuing the last request of the plug list
@ 2022-07-18 12:35 Yufen Yu
  2022-07-19  9:26 ` Ming Lei
  0 siblings, 1 reply; 19+ messages in thread
From: Yufen Yu @ 2022-07-18 12:35 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ming.lei, hch, Yufen Yu

We do test on a virtio scsi device (/dev/sda) and the default mq
scheduler is 'none'. We found a IO hung as following:

blk_finish_plug
  blk_mq_plug_issue_direct
      scsi_mq_get_budget
      //get budget_token fail and sdev->restarts=1

			     	 scsi_end_request
				   scsi_run_queue_async
                                   //sdev->restart=0 and run queue

     blk_mq_request_bypass_insert
        //add request to hctx->dispatch list

  //continue to dispath plug list
  blk_mq_dispatch_plug_list
      blk_mq_try_issue_list_directly
        //success issue all requests from plug list

After .get_budget fail, scsi_mq_get_budget will increase 'restarts'.
Normally, it will run hw queue when io complete and set 'restarts'
as 0. But if we run queue before adding request to the dispatch list
and blk_mq_dispatch_plug_list also success issue all requests, then
on one will run queue, and the request will be stall in the dispatch
list and cannot complete forever.

To fix the bug, we run queue after issuing the last request in
function blk_mq_sched_insert_requests.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/blk-mq-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index a4f7c101b53b..c3ad97ca2753 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -490,8 +490,8 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,
 		blk_mq_insert_requests(hctx, ctx, list);
 	}
 
-	blk_mq_run_hw_queue(hctx, run_queue_async);
  out:
+	blk_mq_run_hw_queue(hctx, run_queue_async);
 	percpu_ref_put(&q->q_usage_counter);
 }
 
-- 
2.31.1


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

end of thread, other threads:[~2022-07-26  9:20 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18 12:35 [PATCH] blk-mq: run queue after issuing the last request of the plug list Yufen Yu
2022-07-19  9:26 ` Ming Lei
2022-07-19 11:00   ` Yufen Yu
2022-07-23  2:50   ` Yu Kuai
2022-07-25 15:43     ` Ming Lei
2022-07-26  1:08       ` Yu Kuai
2022-07-26  1:46         ` Ming Lei
2022-07-26  2:08           ` Yu Kuai
2022-07-26  2:32             ` Ming Lei
2022-07-26  2:52               ` Yu Kuai
2022-07-26  3:02                 ` Ming Lei
2022-07-26  3:14                   ` Yu Kuai
2022-07-26  3:21                     ` Ming Lei
2022-07-26  3:31                       ` Yufen Yu
2022-07-26  3:31                       ` Yu Kuai
2022-07-26  4:16                         ` Ming Lei
2022-07-26  5:01                           ` Yufen Yu
2022-07-26  7:39                             ` Ming Lei
2022-07-26  9:20                               ` Yufen Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox