Commit 89ea5ceb authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

blk-mq: cleanup __blk_mq_sched_dispatch_requests

__blk_mq_sched_dispatch_requests currently has duplicated logic
for the cases where requests are on the hctx dispatch list or not.
Merge the two with a new need_dispatch variable and remove a few
pointless local variables.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20230413060651.694656-2-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b12e5c6c
...@@ -269,9 +269,7 @@ static int blk_mq_do_dispatch_ctx(struct blk_mq_hw_ctx *hctx) ...@@ -269,9 +269,7 @@ static int blk_mq_do_dispatch_ctx(struct blk_mq_hw_ctx *hctx)
static int __blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx) static int __blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx)
{ {
struct request_queue *q = hctx->queue; bool need_dispatch = false;
const bool has_sched = q->elevator;
int ret = 0;
LIST_HEAD(rq_list); LIST_HEAD(rq_list);
/* /*
...@@ -300,23 +298,22 @@ static int __blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx) ...@@ -300,23 +298,22 @@ static int __blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx)
*/ */
if (!list_empty(&rq_list)) { if (!list_empty(&rq_list)) {
blk_mq_sched_mark_restart_hctx(hctx); blk_mq_sched_mark_restart_hctx(hctx);
if (blk_mq_dispatch_rq_list(hctx, &rq_list, 0)) { if (!blk_mq_dispatch_rq_list(hctx, &rq_list, 0))
if (has_sched) return 0;
ret = blk_mq_do_dispatch_sched(hctx); need_dispatch = true;
else } else {
ret = blk_mq_do_dispatch_ctx(hctx); need_dispatch = hctx->dispatch_busy;
} }
} else if (has_sched) {
ret = blk_mq_do_dispatch_sched(hctx); if (hctx->queue->elevator)
} else if (hctx->dispatch_busy) { return blk_mq_do_dispatch_sched(hctx);
/* dequeue request one by one from sw queue if queue is busy */ /* dequeue request one by one from sw queue if queue is busy */
ret = blk_mq_do_dispatch_ctx(hctx); if (need_dispatch)
} else { return blk_mq_do_dispatch_ctx(hctx);
blk_mq_flush_busy_ctxs(hctx, &rq_list); blk_mq_flush_busy_ctxs(hctx, &rq_list);
blk_mq_dispatch_rq_list(hctx, &rq_list, 0); blk_mq_dispatch_rq_list(hctx, &rq_list, 0);
} return 0;
return ret;
} }
void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx) void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx)
......
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