Commit 2b71b877 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

blk-mq: factor out a blk_mq_get_budget_and_tag helper

Factor out a helper from __blk_mq_try_issue_directly in preparation
of folding that function into its two callers.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20230413064057.707578-13-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a1e948b8
...@@ -2624,13 +2624,27 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx, ...@@ -2624,13 +2624,27 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx,
return ret; return ret;
} }
static bool blk_mq_get_budget_and_tag(struct request *rq)
{
int budget_token;
budget_token = blk_mq_get_dispatch_budget(rq->q);
if (budget_token < 0)
return false;
blk_mq_set_rq_budget_token(rq, budget_token);
if (!blk_mq_get_driver_tag(rq)) {
blk_mq_put_dispatch_budget(rq->q, budget_token);
return false;
}
return true;
}
static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
struct request *rq, struct request *rq,
bool bypass_insert, bool last) bool bypass_insert, bool last)
{ {
struct request_queue *q = rq->q; struct request_queue *q = rq->q;
bool run_queue = true; bool run_queue = true;
int budget_token;
/* /*
* RCU or SRCU read lock is needed before checking quiesced flag. * RCU or SRCU read lock is needed before checking quiesced flag.
...@@ -2648,17 +2662,9 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, ...@@ -2648,17 +2662,9 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
if ((rq->rq_flags & RQF_ELV) && !bypass_insert) if ((rq->rq_flags & RQF_ELV) && !bypass_insert)
goto insert; goto insert;
budget_token = blk_mq_get_dispatch_budget(q); if (!blk_mq_get_budget_and_tag(rq))
if (budget_token < 0)
goto insert; goto insert;
blk_mq_set_rq_budget_token(rq, budget_token);
if (!blk_mq_get_driver_tag(rq)) {
blk_mq_put_dispatch_budget(q, budget_token);
goto insert;
}
return __blk_mq_issue_directly(hctx, rq, last); return __blk_mq_issue_directly(hctx, rq, last);
insert: insert:
if (bypass_insert) if (bypass_insert)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment