]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
blk-mq: refactor blk_mq_sched_assign_ioc
authorChristoph Hellwig <hch@lst.de>
Fri, 16 Jun 2017 16:15:25 +0000 (18:15 +0200)
committerJens Axboe <axboe@kernel.dk>
Sun, 18 Jun 2017 16:08:55 +0000 (10:08 -0600)
blk_mq_sched_assign_ioc now only handles the assigned of the ioc if
the schedule needs it (bfq only at the moment).  The caller to the
per-request initializer is moved out so that it can be merged with
a similar call for the kyber I/O scheduler.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq-sched.c
block/blk-mq-sched.h
block/blk-mq.c

index 22601e5c6f1982a67d6c70890fac3303682a8f7f..254d1c164567d72a631385589b2083dc1e972c9e 100644 (file)
@@ -31,12 +31,10 @@ void blk_mq_sched_free_hctx_data(struct request_queue *q,
 }
 EXPORT_SYMBOL_GPL(blk_mq_sched_free_hctx_data);
 
-static void __blk_mq_sched_assign_ioc(struct request_queue *q,
-                                     struct request *rq,
-                                     struct bio *bio,
-                                     struct io_context *ioc)
+void blk_mq_sched_assign_ioc(struct request *rq, struct bio *bio)
 {
-       struct elevator_queue *e = q->elevator;
+       struct request_queue *q = rq->q;
+       struct io_context *ioc = rq_ioc(bio);
        struct io_cq *icq;
 
        spin_lock_irq(q->queue_lock);
@@ -48,26 +46,8 @@ static void __blk_mq_sched_assign_ioc(struct request_queue *q,
                if (!icq)
                        return;
        }
-
-       rq->elv.icq = icq;
-       if (e && e->type->ops.mq.get_rq_priv &&
-           e->type->ops.mq.get_rq_priv(q, rq, bio)) {
-               rq->elv.icq = NULL;
-               return;
-       }
-
-       rq->rq_flags |= RQF_ELVPRIV;
        get_io_context(icq->ioc);
-}
-
-void blk_mq_sched_assign_ioc(struct request_queue *q, struct request *rq,
-                            struct bio *bio)
-{
-       struct io_context *ioc;
-
-       ioc = rq_ioc(bio);
-       if (ioc)
-               __blk_mq_sched_assign_ioc(q, rq, bio, ioc);
+       rq->elv.icq = icq;
 }
 
 void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx)
index f34e6a522105381a694a854eddc5ae8865d5844f..e117edd039b1f2954d8e1d262c12e2800861c713 100644 (file)
@@ -7,8 +7,7 @@
 void blk_mq_sched_free_hctx_data(struct request_queue *q,
                                 void (*exit)(struct blk_mq_hw_ctx *));
 
-void blk_mq_sched_assign_ioc(struct request_queue *q, struct request *rq,
-                            struct bio *bio);
+void blk_mq_sched_assign_ioc(struct request *rq, struct bio *bio);
 
 void blk_mq_sched_request_inserted(struct request *rq);
 bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
index e056725679a82817a98084fdcf6a0ba7c5bacb1b..2f380ab7a603b7a55bf727db6d244d884e5aa76a 100644 (file)
@@ -315,8 +315,18 @@ static struct request *blk_mq_get_request(struct request_queue *q,
 
        if (!op_is_flush(op)) {
                rq->elv.icq = NULL;
-               if (e && e->type->icq_cache)
-                       blk_mq_sched_assign_ioc(q, rq, bio);
+               if (e && e->type->ops.mq.get_rq_priv) {
+                       if (e->type->icq_cache && rq_ioc(bio))
+                               blk_mq_sched_assign_ioc(rq, bio);
+
+                       if (e->type->ops.mq.get_rq_priv(q, rq, bio)) {
+                               if (rq->elv.icq)
+                                       put_io_context(rq->elv.icq->ioc);
+                               rq->elv.icq = NULL;
+                       } else {
+                               rq->rq_flags |= RQF_ELVPRIV;
+                       }
+               }
        }
        data->hctx->queued++;
        return rq;