]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
block: introduce 'blk_mq_ctx' parameter to blk_get_flush_queue
authorMing Lei <ming.lei@canonical.com>
Thu, 25 Sep 2014 15:23:46 +0000 (23:23 +0800)
committerJens Axboe <axboe@fb.com>
Thu, 25 Sep 2014 21:22:44 +0000 (15:22 -0600)
This patch adds 'blk_mq_ctx' parameter to blk_get_flush_queue(),
so that this function can find the corresponding blk_flush_queue
bound with current mq context since the flush queue will become
per hw-queue.

For legacy queue, the parameter can be simply 'NULL'.

For multiqueue case, the parameter should be set as the context
from which the related request is originated. With this context
info, the hw queue and related flush queue can be found easily.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-core.c
block/blk-flush.c
block/blk-mq.c
block/blk.h

index dba0a8350807fd402d2b110405588141dd93828a..b1dd4e086740ab359a37620448c8341b5b62b728 100644 (file)
@@ -390,7 +390,7 @@ static void __blk_drain_queue(struct request_queue *q, bool drain_all)
                 * be drained.  Check all the queues and counters.
                 */
                if (drain_all) {
-                       struct blk_flush_queue *fq = blk_get_flush_queue(q);
+                       struct blk_flush_queue *fq = blk_get_flush_queue(q, NULL);
                        drain |= !list_empty(&q->queue_head);
                        for (i = 0; i < 2; i++) {
                                drain |= q->nr_rqs[i];
index 9bc5b4f35c23adc72dfc7a66f66042a2d1630b9a..004d95e4098e5e4227d28d2292eb0d1d7a38ff73 100644 (file)
@@ -223,7 +223,7 @@ static void flush_end_io(struct request *flush_rq, int error)
        bool queued = false;
        struct request *rq, *n;
        unsigned long flags = 0;
-       struct blk_flush_queue *fq = blk_get_flush_queue(q);
+       struct blk_flush_queue *fq = blk_get_flush_queue(q, flush_rq->mq_ctx);
 
        if (q->mq_ops) {
                spin_lock_irqsave(&fq->mq_flush_lock, flags);
@@ -319,7 +319,7 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq)
 static void flush_data_end_io(struct request *rq, int error)
 {
        struct request_queue *q = rq->q;
-       struct blk_flush_queue *fq = blk_get_flush_queue(q);
+       struct blk_flush_queue *fq = blk_get_flush_queue(q, NULL);
 
        /*
         * After populating an empty queue, kick it to avoid stall.  Read
@@ -333,11 +333,10 @@ static void mq_flush_data_end_io(struct request *rq, int error)
 {
        struct request_queue *q = rq->q;
        struct blk_mq_hw_ctx *hctx;
-       struct blk_mq_ctx *ctx;
+       struct blk_mq_ctx *ctx = rq->mq_ctx;
        unsigned long flags;
-       struct blk_flush_queue *fq = blk_get_flush_queue(q);
+       struct blk_flush_queue *fq = blk_get_flush_queue(q, ctx);
 
-       ctx = rq->mq_ctx;
        hctx = q->mq_ops->map_queue(q, ctx->cpu);
 
        /*
@@ -367,7 +366,7 @@ void blk_insert_flush(struct request *rq)
        struct request_queue *q = rq->q;
        unsigned int fflags = q->flush_flags;   /* may change, cache */
        unsigned int policy = blk_flush_policy(fflags, rq);
-       struct blk_flush_queue *fq = blk_get_flush_queue(q);
+       struct blk_flush_queue *fq = blk_get_flush_queue(q, rq->mq_ctx);
 
        /*
         * @policy now records what operations need to be done.  Adjust
index 59ca79634cb9821739777b3eeac3057f68ab2029..53b6def12fc436111987449c61c7228d96d7de3b 100644 (file)
@@ -518,7 +518,8 @@ static inline bool is_flush_request(struct request *rq,
 struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
 {
        struct request *rq = tags->rqs[tag];
-       struct blk_flush_queue *fq = blk_get_flush_queue(rq->q);
+       /* mq_ctx of flush rq is always cloned from the corresponding req */
+       struct blk_flush_queue *fq = blk_get_flush_queue(rq->q, rq->mq_ctx);
 
        if (!is_flush_request(rq, fq, tag))
                return rq;
index 9eaa6e91b13fa8a98c485e7929a81bf9fae475c8..7ecdd8517e69b30d452f42e6393a1b66dc403ece 100644 (file)
@@ -29,7 +29,7 @@ extern struct kobj_type blk_queue_ktype;
 extern struct ida blk_queue_ida;
 
 static inline struct blk_flush_queue *blk_get_flush_queue(
-               struct request_queue *q)
+               struct request_queue *q, struct blk_mq_ctx *ctx)
 {
        return q->fq;
 }
@@ -106,7 +106,7 @@ void blk_insert_flush(struct request *rq);
 static inline struct request *__elv_next_request(struct request_queue *q)
 {
        struct request *rq;
-       struct blk_flush_queue *fq = blk_get_flush_queue(q);
+       struct blk_flush_queue *fq = blk_get_flush_queue(q, NULL);
 
        while (1) {
                if (!list_empty(&q->queue_head)) {