Skip to content

Commit c53cd18

Browse files
yangerkungregkh
authored andcommitted
blk-mq: call commit_rqs while list empty but error happen
[ Upstream commit 632bfb6 ] 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) <yi.zhang@huawei.com> Signed-off-by: yangerkun <yangerkun@huawei.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a6141f1 commit c53cd18

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎block/blk-mq.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,21 +1304,18 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
13041304

13051305
hctx->dispatched[queued_to_index(queued)]++;
13061306

1307+
/* If we didn't flush the entire list, we could have told the driver
1308+
* there was more coming, but that turned out to be a lie.
1309+
*/
1310+
if ((!list_empty(list) || errors) && q->mq_ops->commit_rqs && queued)
1311+
q->mq_ops->commit_rqs(hctx);
13071312
/*
13081313
* Any items that need requeuing? Stuff them into hctx->dispatch,
13091314
* that is where we will continue on next queue run.
13101315
*/
13111316
if (!list_empty(list)) {
13121317
bool needs_restart;
13131318

1314-
/*
1315-
* If we didn't flush the entire list, we could have told
1316-
* the driver there was more coming, but that turned out to
1317-
* be a lie.
1318-
*/
1319-
if (q->mq_ops->commit_rqs && queued)
1320-
q->mq_ops->commit_rqs(hctx);
1321-
13221319
spin_lock(&hctx->lock);
13231320
list_splice_tail_init(list, &hctx->dispatch);
13241321
spin_unlock(&hctx->lock);
@@ -1971,6 +1968,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
19711968
struct list_head *list)
19721969
{
19731970
int queued = 0;
1971+
int errors = 0;
19741972

19751973
while (!list_empty(list)) {
19761974
blk_status_t ret;
@@ -1987,6 +1985,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
19871985
break;
19881986
}
19891987
blk_mq_end_request(rq, ret);
1988+
errors++;
19901989
} else
19911990
queued++;
19921991
}
@@ -1996,7 +1995,8 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
19961995
* the driver there was more coming, but that turned out to
19971996
* be a lie.
19981997
*/
1999-
if (!list_empty(list) && hctx->queue->mq_ops->commit_rqs && queued)
1998+
if ((!list_empty(list) || errors) &&
1999+
hctx->queue->mq_ops->commit_rqs && queued)
20002000
hctx->queue->mq_ops->commit_rqs(hctx);
20012001
}
20022002

0 commit comments

Comments
 (0)