From: Bart Van Assche <bvanassche@acm.org>
Date: Mon, 1 Jul 2019 08:47:30 -0700
Subject: blk-mq: simplify blk_mq_make_request()
Git-commit: 970d168de636ddac8221cbd4a11d7678943e7379
Patch-mainline: v5.3-rc1
References: bsc#1165478
Move the blk_mq_bio_to_request() call in front of the if-statement.
Cc: Hannes Reinecke <hare@suse.com>
Cc: Omar Sandoval <osandov@fb.com>
Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Acked-by: Martin Wilck <mwilck@suse.com>
---
block/blk-mq.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1885,10 +1885,11 @@ static blk_qc_t blk_mq_make_request(stru
cookie = request_to_qc_t(data.hctx, rq);
+ blk_mq_bio_to_request(rq, bio);
+
plug = current->plug;
if (unlikely(is_flush_fua)) {
blk_mq_put_ctx(data.ctx);
- blk_mq_bio_to_request(rq, bio);
/* bypass scheduler for flush rq */
blk_insert_flush(rq);
@@ -1897,7 +1898,6 @@ static blk_qc_t blk_mq_make_request(stru
struct request *last = NULL;
blk_mq_put_ctx(data.ctx);
- blk_mq_bio_to_request(rq, bio);
/*
* @request_count may become stale because of schedule
@@ -1921,7 +1921,6 @@ static blk_qc_t blk_mq_make_request(stru
list_add_tail(&rq->queuelist, &plug->mq_list);
} else if (plug && !blk_queue_nomerges(q)) {
- blk_mq_bio_to_request(rq, bio);
/*
* We do limited plugging. If the bio can be merged, do that.
@@ -1947,11 +1946,9 @@ static blk_qc_t blk_mq_make_request(stru
} else if ((q->nr_hw_queues > 1 && is_sync) || (!q->elevator &&
!data.hctx->dispatch_busy)) {
blk_mq_put_ctx(data.ctx);
- blk_mq_bio_to_request(rq, bio);
blk_mq_try_issue_directly(data.hctx, rq, &cookie);
} else {
blk_mq_put_ctx(data.ctx);
- blk_mq_bio_to_request(rq, bio);
blk_mq_sched_insert_request(rq, false, true, true);
}