Skip to content

Commit d3b3859

Browse files
Yufen Yuaxboe
authored andcommitted
blk-mq: run queue no matter whether the request is the last request
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. It is wrong to use last request of plug list to decide if run queue is needed since all the remained requests in plug list may be from other hctxs. To fix the bug, pass run_queue as true always to blk_mq_request_bypass_insert(). Fix-suggested-by: Ming Lei <[email protected]> Signed-off-by: Yufen Yu <[email protected]> Reviewed-by: Ming Lei <[email protected]> Fixes: dc5fc36 ("block: attempt direct issue of plug list") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a8239f0 commit d3b3859

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-mq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2550,7 +2550,7 @@ static void blk_mq_plug_issue_direct(struct blk_plug *plug, bool from_schedule)
25502550
break;
25512551
case BLK_STS_RESOURCE:
25522552
case BLK_STS_DEV_RESOURCE:
2553-
blk_mq_request_bypass_insert(rq, false, last);
2553+
blk_mq_request_bypass_insert(rq, false, true);
25542554
blk_mq_commit_rqs(hctx, &queued, from_schedule);
25552555
return;
25562556
default:

0 commit comments

Comments
 (0)