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@xxxxxx> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- 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