Commit 5f550ede authored by Jan Kara's avatar Jan Kara Committed by Jens Axboe

bfq: Remove pointless bfq_init_rq() calls

We call bfq_init_rq() from request merging functions where requests we
get should have already gone through bfq_init_rq() during insert and
anyway we want to do anything only if the request is already tracked by
BFQ. So replace calls to bfq_init_rq() with RQ_BFQQ() instead to simply
skip requests untracked by BFQ. We move bfq_init_rq() call in
bfq_insert_request() a bit earlier to cover request merging and thus
can transfer FIFO position in case of a merge.

CC: stable@vger.kernel.org
Tested-by: default avatar"yukuai (C)" <yukuai3@huawei.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220401102752.8599-6-jack@suse.czSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent fc84e1f9
...@@ -2497,8 +2497,6 @@ static int bfq_request_merge(struct request_queue *q, struct request **req, ...@@ -2497,8 +2497,6 @@ static int bfq_request_merge(struct request_queue *q, struct request **req,
return ELEVATOR_NO_MERGE; return ELEVATOR_NO_MERGE;
} }
static struct bfq_queue *bfq_init_rq(struct request *rq);
static void bfq_request_merged(struct request_queue *q, struct request *req, static void bfq_request_merged(struct request_queue *q, struct request *req,
enum elv_merge type) enum elv_merge type)
{ {
...@@ -2507,7 +2505,7 @@ static void bfq_request_merged(struct request_queue *q, struct request *req, ...@@ -2507,7 +2505,7 @@ static void bfq_request_merged(struct request_queue *q, struct request *req,
blk_rq_pos(req) < blk_rq_pos(req) <
blk_rq_pos(container_of(rb_prev(&req->rb_node), blk_rq_pos(container_of(rb_prev(&req->rb_node),
struct request, rb_node))) { struct request, rb_node))) {
struct bfq_queue *bfqq = bfq_init_rq(req); struct bfq_queue *bfqq = RQ_BFQQ(req);
struct bfq_data *bfqd; struct bfq_data *bfqd;
struct request *prev, *next_rq; struct request *prev, *next_rq;
...@@ -2559,8 +2557,8 @@ static void bfq_request_merged(struct request_queue *q, struct request *req, ...@@ -2559,8 +2557,8 @@ static void bfq_request_merged(struct request_queue *q, struct request *req,
static void bfq_requests_merged(struct request_queue *q, struct request *rq, static void bfq_requests_merged(struct request_queue *q, struct request *rq,
struct request *next) struct request *next)
{ {
struct bfq_queue *bfqq = bfq_init_rq(rq), struct bfq_queue *bfqq = RQ_BFQQ(rq),
*next_bfqq = bfq_init_rq(next); *next_bfqq = RQ_BFQQ(next);
if (!bfqq) if (!bfqq)
goto remove; goto remove;
...@@ -6129,6 +6127,8 @@ static inline void bfq_update_insert_stats(struct request_queue *q, ...@@ -6129,6 +6127,8 @@ static inline void bfq_update_insert_stats(struct request_queue *q,
unsigned int cmd_flags) {} unsigned int cmd_flags) {}
#endif /* CONFIG_BFQ_CGROUP_DEBUG */ #endif /* CONFIG_BFQ_CGROUP_DEBUG */
static struct bfq_queue *bfq_init_rq(struct request *rq);
static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
bool at_head) bool at_head)
{ {
...@@ -6144,6 +6144,7 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, ...@@ -6144,6 +6144,7 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
bfqg_stats_update_legacy_io(q, rq); bfqg_stats_update_legacy_io(q, rq);
#endif #endif
spin_lock_irq(&bfqd->lock); spin_lock_irq(&bfqd->lock);
bfqq = bfq_init_rq(rq);
if (blk_mq_sched_try_insert_merge(q, rq, &free)) { if (blk_mq_sched_try_insert_merge(q, rq, &free)) {
spin_unlock_irq(&bfqd->lock); spin_unlock_irq(&bfqd->lock);
blk_mq_free_requests(&free); blk_mq_free_requests(&free);
...@@ -6152,7 +6153,6 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, ...@@ -6152,7 +6153,6 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
trace_block_rq_insert(rq); trace_block_rq_insert(rq);
bfqq = bfq_init_rq(rq);
if (!bfqq || at_head) { if (!bfqq || at_head) {
if (at_head) if (at_head)
list_add(&rq->queuelist, &bfqd->dispatch); list_add(&rq->queuelist, &bfqd->dispatch);
......
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