blk-mq: simplify flush check in blk_mq_dispatch_rq_list
authorKemeng Shi <shikemeng@huaweicloud.com>
Wed, 18 Jan 2023 09:37:22 +0000 (17:37 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 6 Feb 2023 16:22:28 +0000 (09:22 -0700)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c

index a032d72..07256cd 100644 (file)
@@ -2108,9 +2108,9 @@ out:
        /* 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, false);
+
        /*
         * Any items that need requeuing? Stuff them into hctx->dispatch,
         * that is where we will continue on next queue run.