diff mbox series

[v3,10/14] blk-mq: simplify flush check in blk_mq_dispatch_rq_list

Message ID 20230111130159.3741753-11-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
1. Remove check of needs_resource and ret == BLK_STS_DEV_RESOURCE.
For busy error BLK_STS*_RESOURCE, request will always be added
back to list, so need_resource will not be true and ret will
not be == BLK_STS_DEV_RESOURCE if list is empty. We could remove
these dead check.

2. Check ret of last request instead of errors
If list is empty, we only need to explicitly commit_rqs
if error happens at last request which is stored in ret. So check
ret of last request instead of errors to remove unnecessary
commit_rqs triggered by errors returned from previous request.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 block/blk-mq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Jan. 11, 2023, 5:45 a.m. UTC | #1
> +	if ((!list_empty(list) || ret != BLK_STS_OK))

Plase drop the double braces.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f45d81e20d9e..8fd25713751c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2114,9 +2114,9 @@  bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
 	/* 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 ((!list_empty(list) || errors || needs_resource ||
-	     ret == BLK_STS_DEV_RESOURCE) && q->mq_ops->commit_rqs && queued)
-		q->mq_ops->commit_rqs(hctx);
+	if ((!list_empty(list) || ret != BLK_STS_OK))
+		blk_mq_commit_rqs(hctx, queued);
+
 	/*
 	 * Any items that need requeuing? Stuff them into hctx->dispatch,
 	 * that is where we will continue on next queue run.