diff mbox series

[v3,09/14] blk-mq: use blk_mq_commit_rqs helper in blk_mq_try_issue_list_directly

Message ID 20230111130159.3741753-10-shikemeng@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series A few bugfix and cleanup patches for blk-mq | expand

Commit Message

Kemeng Shi Jan. 11, 2023, 1:01 p.m. UTC
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: Kemeng Shi <shikemeng@huaweicloud.com>
---
 block/blk-mq.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Christoph Hellwig Jan. 11, 2023, 5:19 a.m. UTC | #1
On Wed, Jan 11, 2023 at 09:01:54PM +0800, Kemeng Shi wrote:
> +	blk_status_t ret;

Same here, I think ret needs to be initialized now.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index c6c84f44c7a6..f45d81e20d9e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2819,17 +2819,15 @@  void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
 		struct list_head *list)
 {
 	int queued = 0;
-	int errors = 0;
+	blk_status_t ret;
 
 	while (!list_empty(list)) {
-		blk_status_t ret;
 		struct request *rq = list_first_entry(list, struct request,
 				queuelist);
 
 		list_del_init(&rq->queuelist);
 		ret = blk_mq_request_issue_directly(rq, list_empty(list));
 		if (ret != BLK_STS_OK) {
-			errors++;
 			if (ret == BLK_STS_RESOURCE ||
 					ret == BLK_STS_DEV_RESOURCE) {
 				blk_mq_request_bypass_insert(rq, false,
@@ -2841,13 +2839,8 @@  void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
 			queued++;
 	}
 
-	/*
-	 * If we didn't flush the entire list, we could have told
-	 * 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);
+	if (ret != BLK_STS_OK)
+		blk_mq_commit_rqs(hctx, queued);
 }
 
 static bool blk_mq_attempt_bio_merge(struct request_queue *q,