Skip to content

Commit

Permalink
blk-mq: release driver tag on a requeue event
Browse files Browse the repository at this point in the history
We don't want to hold on to this resource when we have a scheduler
attached.

Signed-off-by: Jens Axboe <[email protected]>
Reviewed-by: Omar Sandoval <[email protected]>
Tested-by: Hannes Reinecke <[email protected]>
  • Loading branch information
axboe committed Jan 27, 2017
1 parent 3c782d6 commit 99cf1dc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,21 @@ static bool blk_mq_get_driver_tag(struct request *rq,
return false;
}

static void blk_mq_put_driver_tag(struct blk_mq_hw_ctx *hctx,
struct request *rq)
{
if (rq->tag == -1 || rq->internal_tag == -1)
return;

blk_mq_put_tag(hctx, hctx->tags, rq->mq_ctx, rq->tag);
rq->tag = -1;

if (rq->rq_flags & RQF_MQ_INFLIGHT) {
rq->rq_flags &= ~RQF_MQ_INFLIGHT;
atomic_dec(&hctx->nr_active);
}
}

/*
* If we fail getting a driver tag because all the driver tags are already
* assigned and on the dispatch list, BUT the first entry does not have a
Expand Down Expand Up @@ -951,6 +966,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
queued++;
break;
case BLK_MQ_RQ_QUEUE_BUSY:
blk_mq_put_driver_tag(hctx, rq);
list_add(&rq->queuelist, list);
__blk_mq_requeue_request(rq);
break;
Expand Down

0 comments on commit 99cf1dc

Please sign in to comment.