Skip to content

Commit 632bfb6

Browse files
yangerkunaxboe
authored andcommitted
blk-mq: call commit_rqs while list empty but error happen
Blk-mq should call commit_rqs once 'bd.last != true' and no more request will come(so virtscsi can kick the virtqueue, e.g.). We already do that in 'blk_mq_dispatch_rq_list/blk_mq_try_issue_list_directly' while list not empty and 'queued > 0'. However, we can seen the same scene once the last request in list call queue_rq and return error like BLK_STS_IOERR which will not requeue the request, and lead that list empty but need call commit_rqs too(Or the request for virtscsi will stay timeout until other request kick virtqueue). We found this problem by do fsstress test with offline/online virtscsi device repeat quickly. Fixes: d666ba9 ("blk-mq: add mq_ops->commit_rqs()") Reported-by: zhangyi (F) <[email protected]> Signed-off-by: yangerkun <[email protected]> Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 3aab917 commit 632bfb6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

block/blk-mq.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,11 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
14121412

14131413
hctx->dispatched[queued_to_index(queued)]++;
14141414

1415+
/* If we didn't flush the entire list, we could have told the driver
1416+
* there was more coming, but that turned out to be a lie.
1417+
*/
1418+
if ((!list_empty(list) || errors) && q->mq_ops->commit_rqs && queued)
1419+
q->mq_ops->commit_rqs(hctx);
14151420
/*
14161421
* Any items that need requeuing? Stuff them into hctx->dispatch,
14171422
* that is where we will continue on next queue run.
@@ -1425,14 +1430,6 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
14251430

14261431
blk_mq_release_budgets(q, nr_budgets);
14271432

1428-
/*
1429-
* If we didn't flush the entire list, we could have told
1430-
* the driver there was more coming, but that turned out to
1431-
* be a lie.
1432-
*/
1433-
if (q->mq_ops->commit_rqs && queued)
1434-
q->mq_ops->commit_rqs(hctx);
1435-
14361433
spin_lock(&hctx->lock);
14371434
list_splice_tail_init(list, &hctx->dispatch);
14381435
spin_unlock(&hctx->lock);
@@ -2079,6 +2076,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
20792076
struct list_head *list)
20802077
{
20812078
int queued = 0;
2079+
int errors = 0;
20822080

20832081
while (!list_empty(list)) {
20842082
blk_status_t ret;
@@ -2095,6 +2093,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
20952093
break;
20962094
}
20972095
blk_mq_end_request(rq, ret);
2096+
errors++;
20982097
} else
20992098
queued++;
21002099
}
@@ -2104,7 +2103,8 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
21042103
* the driver there was more coming, but that turned out to
21052104
* be a lie.
21062105
*/
2107-
if (!list_empty(list) && hctx->queue->mq_ops->commit_rqs && queued)
2106+
if ((!list_empty(list) || errors) &&
2107+
hctx->queue->mq_ops->commit_rqs && queued)
21082108
hctx->queue->mq_ops->commit_rqs(hctx);
21092109
}
21102110

0 commit comments

Comments
 (0)