On Fri, May 09, 2014 at 08:00:18AM -0700, Christoph Hellwig wrote:
> On Fri, May 09, 2014 at 08:07:33PM +0800, Shaohua Li wrote:
> > 
> > flush request is special, which borrows tag from other request. Need a 
> > special
> > handling to get it from tag.
> 
> Thanks, we probably need this one.  But I think you can simply test
> REQ_FLUSH_SEQ the passed in request instead of the flush_rq_tag_valid
> flag/

fair enough. updated one.

 
Subject: blk-mq: blk_mq_tag_to_rq should handle flush request

flush request is special, which borrows tag from other request. Need a special
handling to get it from tag.

Signed-off-by: Shaohua Li <[email protected]>
---
 block/blk-flush.c                 |    4 +++-
 block/blk-mq.c                    |    8 ++++++--
 drivers/block/mtip32xx/mtip32xx.c |    2 +-
 include/linux/blk-mq.h            |    3 ++-
 4 files changed, 12 insertions(+), 5 deletions(-)

Index: linux/block/blk-flush.c
===================================================================
--- linux.orig/block/blk-flush.c        2014-05-10 11:49:21.646830000 +0800
+++ linux/block/blk-flush.c     2014-05-10 11:49:21.638830100 +0800
@@ -231,8 +231,10 @@ static void flush_end_io(struct request
        struct request *rq, *n;
        unsigned long flags = 0;
 
-       if (q->mq_ops)
+       if (q->mq_ops) {
                spin_lock_irqsave(&q->mq_flush_lock, flags);
+               q->flush_rq->cmd_flags = 0;
+       }
 
        running = &q->flush_queue[q->flush_running_idx];
        BUG_ON(q->flush_pending_idx == q->flush_running_idx);
Index: linux/block/blk-mq.c
===================================================================
--- linux.orig/block/blk-mq.c   2014-05-10 11:49:21.646830000 +0800
+++ linux/block/blk-mq.c        2014-05-10 11:49:21.638830100 +0800
@@ -481,8 +481,12 @@ void blk_mq_requeue_request(struct reque
 }
 EXPORT_SYMBOL(blk_mq_requeue_request);
 
-struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
+struct request *blk_mq_tag_to_rq(struct request_queue *q,
+       struct blk_mq_tags *tags, unsigned int tag)
 {
+       if ((q->flush_rq->cmd_flags & REQ_FLUSH_SEQ) &&
+           q->flush_rq->tag == tag)
+               return q->flush_rq;
        return tags->rqs[tag];
 }
 EXPORT_SYMBOL(blk_mq_tag_to_rq);
@@ -512,7 +516,7 @@ static void blk_mq_timeout_check(void *_
                if (tag >= hctx->tags->nr_tags)
                        break;
 
-               rq = blk_mq_tag_to_rq(hctx->tags, tag++);
+               rq = blk_mq_tag_to_rq(hctx->queue, hctx->tags, tag++);
                if (rq->q != hctx->queue)
                        continue;
                if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags))
Index: linux/include/linux/blk-mq.h
===================================================================
--- linux.orig/include/linux/blk-mq.h   2014-05-10 11:49:21.646830000 +0800
+++ linux/include/linux/blk-mq.h        2014-05-10 11:49:21.638830100 +0800
@@ -149,7 +149,8 @@ void blk_mq_free_request(struct request
 bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
 struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t 
gfp);
 struct request *blk_mq_alloc_reserved_request(struct request_queue *q, int rw, 
gfp_t gfp);
-struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
+struct request *blk_mq_tag_to_rq(struct request_queue *q,
+       struct blk_mq_tags *tags, unsigned int tag);
 
 struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int 
ctx_index);
 struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, 
unsigned int);
Index: linux/drivers/block/mtip32xx/mtip32xx.c
===================================================================
--- linux.orig/drivers/block/mtip32xx/mtip32xx.c        2014-05-10 
11:49:21.646830000 +0800
+++ linux/drivers/block/mtip32xx/mtip32xx.c     2014-05-10 11:49:21.638830100 
+0800
@@ -195,7 +195,7 @@ static struct request *mtip_rq_from_tag(
 {
        struct blk_mq_hw_ctx *hctx = dd->queue->queue_hw_ctx[0];
 
-       return blk_mq_tag_to_rq(hctx->tags, tag);
+       return blk_mq_tag_to_rq(dd->queue, hctx->tags, tag);
 }
 
 static struct mtip_cmd *mtip_cmd_from_tag(struct driver_data *dd,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to