Skip to content

Commit 99cf1dc

Browse files
committed
blk-mq: release driver tag on a requeue event
We don't want to hold on to this resource when we have a scheduler attached. Signed-off-by: Jens Axboe <axboe@fb.com> Reviewed-by: Omar Sandoval <osandov@fb.com> Tested-by: Hannes Reinecke <hare@suse.com>
1 parent 3c782d6 commit 99cf1dc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

block/blk-mq.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,21 @@ static bool blk_mq_get_driver_tag(struct request *rq,
879879
return false;
880880
}
881881

882+
static void blk_mq_put_driver_tag(struct blk_mq_hw_ctx *hctx,
883+
struct request *rq)
884+
{
885+
if (rq->tag == -1 || rq->internal_tag == -1)
886+
return;
887+
888+
blk_mq_put_tag(hctx, hctx->tags, rq->mq_ctx, rq->tag);
889+
rq->tag = -1;
890+
891+
if (rq->rq_flags & RQF_MQ_INFLIGHT) {
892+
rq->rq_flags &= ~RQF_MQ_INFLIGHT;
893+
atomic_dec(&hctx->nr_active);
894+
}
895+
}
896+
882897
/*
883898
* If we fail getting a driver tag because all the driver tags are already
884899
* assigned and on the dispatch list, BUT the first entry does not have a
@@ -951,6 +966,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
951966
queued++;
952967
break;
953968
case BLK_MQ_RQ_QUEUE_BUSY:
969+
blk_mq_put_driver_tag(hctx, rq);
954970
list_add(&rq->queuelist, list);
955971
__blk_mq_requeue_request(rq);
956972
break;

0 commit comments

Comments
 (0)