Move code for queueing rq into one helper, so that blk_mq_dispatch_rq_list gets a bit simpified, and easier to read. No functional change. Cc: Sagi Grimberg <sagi@xxxxxxxxxxx> Cc: Baolin Wang <baolin.wang7@xxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- block/blk-mq.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index c06421faa555..34fd09adb7fc 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1220,6 +1220,17 @@ static enum prep_dispatch blk_mq_prep_dispatch_rq(struct request *rq, return PREP_DISPATCH_OK; } +static blk_status_t blk_mq_dispatch_rq(struct request *rq, bool is_last) +{ + struct blk_mq_queue_data bd; + + list_del_init(&rq->queuelist); + bd.rq = rq; + bd.last = is_last; + + return rq->q->mq_ops->queue_rq(rq->mq_hctx, &bd); +} + /* * Returns true if we did some work AND can potentially do more. */ @@ -1243,8 +1254,6 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list, */ errors = queued = 0; do { - struct blk_mq_queue_data bd; - rq = list_first_entry(list, struct request, queuelist); WARN_ON_ONCE(hctx != rq->mq_hctx); @@ -1252,12 +1261,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list, if (prep != PREP_DISPATCH_OK) break; - list_del_init(&rq->queuelist); - - bd.rq = rq; - bd.last = !!list_empty(list); - - ret = q->mq_ops->queue_rq(hctx, &bd); + ret = blk_mq_dispatch_rq(rq, list_is_singular(list)); if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) { blk_mq_handle_dev_resource(rq, list); break; -- 2.25.2