Skip to content

Commit 2b71b87

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20230413064057.707578-13-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a1e948b commit 2b71b87

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

block/blk-mq.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,13 +2624,27 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx,
26242624
return ret;
26252625
}
26262626

2627+
static bool blk_mq_get_budget_and_tag(struct request *rq)
2628+
{
2629+
int budget_token;
2630+
2631+
budget_token = blk_mq_get_dispatch_budget(rq->q);
2632+
if (budget_token < 0)
2633+
return false;
2634+
blk_mq_set_rq_budget_token(rq, budget_token);
2635+
if (!blk_mq_get_driver_tag(rq)) {
2636+
blk_mq_put_dispatch_budget(rq->q, budget_token);
2637+
return false;
2638+
}
2639+
return true;
2640+
}
2641+
26272642
static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
26282643
struct request *rq,
26292644
bool bypass_insert, bool last)
26302645
{
26312646
struct request_queue *q = rq->q;
26322647
bool run_queue = true;
2633-
int budget_token;
26342648

26352649
/*
26362650
* RCU or SRCU read lock is needed before checking quiesced flag.
@@ -2648,16 +2662,8 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
26482662
if ((rq->rq_flags & RQF_ELV) && !bypass_insert)
26492663
goto insert;
26502664

2651-
budget_token = blk_mq_get_dispatch_budget(q);
2652-
if (budget_token < 0)
2653-
goto insert;
2654-
2655-
blk_mq_set_rq_budget_token(rq, budget_token);
2656-
2657-
if (!blk_mq_get_driver_tag(rq)) {
2658-
blk_mq_put_dispatch_budget(q, budget_token);
2665+
if (!blk_mq_get_budget_and_tag(rq))
26592666
goto insert;
2660-
}
26612667

26622668
return __blk_mq_issue_directly(hctx, rq, last);
26632669
insert:

0 commit comments

Comments
 (0)