diff options
author | Christoph Hellwig <hch@lst.de> | 2023-04-13 08:40:49 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-04-13 14:52:30 +0200 |
commit | 2b71b8770710f2913e29053f01b6c7df1a5c7f75 (patch) | |
tree | 12a45d91679cad92fa2d29658e398e377d48c7c7 /block | |
parent | blk-mq: refactor the DONTPREP/SOFTBARRIER andling in blk_mq_requeue_work (diff) | |
download | linux-2b71b8770710f2913e29053f01b6c7df1a5c7f75.tar.xz linux-2b71b8770710f2913e29053f01b6c7df1a5c7f75.zip |
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>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-mq.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index d17871c237f7..5cb7ebefc88c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2624,13 +2624,27 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx, 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, struct request *rq, bool bypass_insert, bool last) { struct request_queue *q = rq->q; bool run_queue = true; - int budget_token; /* * 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, if ((rq->rq_flags & RQF_ELV) && !bypass_insert) goto insert; - budget_token = blk_mq_get_dispatch_budget(q); - if (budget_token < 0) - 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); + if (!blk_mq_get_budget_and_tag(rq)) goto insert; - } return __blk_mq_issue_directly(hctx, rq, last); insert: |