linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blk-mq: put driver tag when this request is completed
@ 2020-06-29  9:47 Ming Lei
  2020-06-29 15:04 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Ming Lei @ 2020-06-29  9:47 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Christoph Hellwig

It is natural to release driver tag when this request is completed by
LLD or device since its purpose is for LLD use.

One big benefit is that the released tag can be re-used quicker since
bio_endio() may take too long.

Meantime we don't need to release driver tag for flush request.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-flush.c | 6 ------
 block/blk-mq.c    | 2 ++
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 15ae0155ec07..21108a550fbf 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -240,7 +240,6 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)
 		blk_mq_tag_set_rq(hctx, flush_rq->tag, fq->orig_rq);
 		flush_rq->tag = -1;
 	} else {
-		blk_mq_put_driver_tag(flush_rq);
 		flush_rq->internal_tag = -1;
 	}
 
@@ -341,11 +340,6 @@ static void mq_flush_data_end_io(struct request *rq, blk_status_t error)
 	unsigned long flags;
 	struct blk_flush_queue *fq = blk_get_flush_queue(q, ctx);
 
-	if (q->elevator) {
-		WARN_ON(rq->tag < 0);
-		blk_mq_put_driver_tag(rq);
-	}
-
 	/*
 	 * After populating an empty queue, kick it to avoid stall.  Read
 	 * the comment in flush_end_io().
diff --git a/block/blk-mq.c b/block/blk-mq.c
index b8738b3c6d06..d07e55455726 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -674,6 +674,8 @@ bool blk_mq_complete_request_remote(struct request *rq)
 {
 	WRITE_ONCE(rq->state, MQ_RQ_COMPLETE);
 
+	blk_mq_put_driver_tag(rq);
+
 	/*
 	 * For a polled request, always complete locallly, it's pointless
 	 * to redirect the completion.
-- 
2.25.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH] blk-mq: put driver tag when this request is completed
@ 2020-07-06 14:40 Ming Lei
  0 siblings, 0 replies; 15+ messages in thread
From: Ming Lei @ 2020-07-06 14:40 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Christoph Hellwig

It is natural to release driver tag when this request is completed by
LLD or device since its purpose is for LLD use.

One big benefit is that the released tag can be re-used quicker since
bio_endio() may take too long.

.complete() is usually called for notifying block layer that this request
is completed from LLD, and it is often the last thing done wrt. completion
from LLD viewpoint. Not see rq->tag is used in driver's complete() too.

Remove the warn in flush code because the driver tag should be released
in normal completion path, however we can't kill it because request may
be done directly via blk_mq_end_request(). Meantime not necessary to
check q->elevator cause blk_mq_put_driver_tag() has run the same check
already.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-flush.c | 5 +----
 block/blk-mq.c    | 2 ++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 15ae0155ec07..86a8b6e747df 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -341,10 +341,7 @@ static void mq_flush_data_end_io(struct request *rq, blk_status_t error)
 	unsigned long flags;
 	struct blk_flush_queue *fq = blk_get_flush_queue(q, ctx);
 
-	if (q->elevator) {
-		WARN_ON(rq->tag < 0);
-		blk_mq_put_driver_tag(rq);
-	}
+	blk_mq_put_driver_tag(rq);
 
 	/*
 	 * After populating an empty queue, kick it to avoid stall.  Read
diff --git a/block/blk-mq.c b/block/blk-mq.c
index abcf590f6238..117dec9abace 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -670,6 +670,8 @@ bool blk_mq_complete_request_remote(struct request *rq)
 {
 	WRITE_ONCE(rq->state, MQ_RQ_COMPLETE);
 
+	blk_mq_put_driver_tag(rq);
+
 	/*
 	 * For a polled request, always complete locallly, it's pointless
 	 * to redirect the completion.
-- 
2.25.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-07-06 14:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29  9:47 [PATCH] blk-mq: put driver tag when this request is completed Ming Lei
2020-06-29 15:04 ` Christoph Hellwig
2020-06-29 15:56 ` Jens Axboe
     [not found] ` <CGME20200701130104eucas1p1f8dcce58bf704b726aee1e89980fe19e@eucas1p1.samsung.com>
2020-07-01 13:01   ` Marek Szyprowski
2020-07-01 13:45     ` Ming Lei
2020-07-01 14:16       ` Marek Szyprowski
2020-07-01 14:58         ` Marek Szyprowski
2020-07-02  1:22         ` Ming Lei
2020-07-02  5:03           ` Jens Axboe
2020-07-02  8:04           ` Marek Szyprowski
2020-07-02  9:23             ` Ming Lei
2020-07-02 10:19               ` Marek Szyprowski
2020-07-02 11:48                 ` Ming Lei
2020-07-02 12:12                   ` Marek Szyprowski
2020-07-06 14:40 Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).