Commit 984ce0a7 authored by Kemeng Shi's avatar Kemeng Shi Committed by Jens Axboe

blk-mq: use blk_mq_commit_rqs helper in blk_mq_try_issue_list_directly

Call blk_mq_commit_rqs instead of access ->commit_rqs directly. As you
can see in comment of blk_mq_commit_rqs, we only need explicitly call
this in two cases:
 -did not queue everything initially scheduled to queue
 -the last attempt to queue a request failed
Both cases can be checked with ret of last request which breaks list
walk. Then we can remove unnecessary error count and unnecessary
commit triggered by error besides cases described above.
Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0d617a83
...@@ -2815,17 +2815,15 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx, ...@@ -2815,17 +2815,15 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
struct list_head *list) struct list_head *list)
{ {
int queued = 0; int queued = 0;
int errors = 0; blk_status_t ret = BLK_STS_OK;
while (!list_empty(list)) { while (!list_empty(list)) {
blk_status_t ret;
struct request *rq = list_first_entry(list, struct request, struct request *rq = list_first_entry(list, struct request,
queuelist); queuelist);
list_del_init(&rq->queuelist); list_del_init(&rq->queuelist);
ret = blk_mq_request_issue_directly(rq, list_empty(list)); ret = blk_mq_request_issue_directly(rq, list_empty(list));
if (ret != BLK_STS_OK) { if (ret != BLK_STS_OK) {
errors++;
if (ret == BLK_STS_RESOURCE || if (ret == BLK_STS_RESOURCE ||
ret == BLK_STS_DEV_RESOURCE) { ret == BLK_STS_DEV_RESOURCE) {
blk_mq_request_bypass_insert(rq, false, blk_mq_request_bypass_insert(rq, false,
...@@ -2837,13 +2835,8 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx, ...@@ -2837,13 +2835,8 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
queued++; queued++;
} }
/* if (ret != BLK_STS_OK)
* If we didn't flush the entire list, we could have told blk_mq_commit_rqs(hctx, queued, false);
* the driver there was more coming, but that turned out to
* be a lie.
*/
if (errors && hctx->queue->mq_ops->commit_rqs && queued)
hctx->queue->mq_ops->commit_rqs(hctx);
} }
static bool blk_mq_attempt_bio_merge(struct request_queue *q, static bool blk_mq_attempt_bio_merge(struct request_queue *q,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment