]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
blk-mq: split the plug and sync cases in blk_mq_make_request
authorChristoph Hellwig <hch@lst.de>
Wed, 22 Mar 2017 19:01:52 +0000 (15:01 -0400)
committerJens Axboe <axboe@fb.com>
Thu, 23 Mar 2017 02:17:01 +0000 (20:17 -0600)
Now that we have a nice direct issue heper this helps simplifying
the code a bit, and also gets rid of the old_rq variable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq.c

index e82e1a9c7d5edd3eae060bcdfb625880ff29ffc4..a9d2e02a8e02223443ca1682aa5a76b8da664450 100644 (file)
@@ -1569,32 +1569,32 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
 
                list_add_tail(&rq->queuelist, &plug->mq_list);
                goto done;
-       } else if (((plug && !blk_queue_nomerges(q)) || is_sync)) {
-               struct request *old_rq = NULL;
-
+       } 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.
                 * Otherwise the existing request in the plug list will be
                 * issued. So the plug list will have one request at most
+                * The plug list might get flushed before this. If that happens,
+                * the plug list is empty, and same_queue_rq is invalid.
                 */
-               if (plug) {
-                       /*
-                        * The plug list might get flushed before this. If that
-                        * happens, same_queue_rq is invalid and plug list is
-                        * empty
-                        */
-                       if (same_queue_rq && !list_empty(&plug->mq_list)) {
-                               old_rq = same_queue_rq;
-                               list_del_init(&old_rq->queuelist);
-                       }
-                       list_add_tail(&rq->queuelist, &plug->mq_list);
-               } else /* is_sync */
-                       old_rq = rq;
+               if (list_empty(&plug->mq_list))
+                       same_queue_rq = NULL;
+               if (same_queue_rq)
+                       list_del_init(&same_queue_rq->queuelist);
+               list_add_tail(&rq->queuelist, &plug->mq_list);
+
+               blk_mq_put_ctx(data.ctx);
+               if (same_queue_rq)
+                       blk_mq_try_issue_directly(data.hctx, same_queue_rq,
+                                       &cookie);
+               goto done;
+       } else if (is_sync) {
+               blk_mq_bio_to_request(rq, bio);
+
                blk_mq_put_ctx(data.ctx);
-               if (old_rq)
-                       blk_mq_try_issue_directly(data.hctx, old_rq, &cookie);
+               blk_mq_try_issue_directly(data.hctx, rq, &cookie);
                goto done;
        }