@@ -783,17 +783,16 @@ void __cold
bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq)
{
struct rb_node **p, *parent;
- struct bfq_queue *__bfqq;
+
+ /* oom_bfqq does not participate in queue merging */
+ if (bfqq == &bfqd->oom_bfqq)
+ return;
if (bfqq->pos_root) {
rb_erase(&bfqq->pos_node, bfqq->pos_root);
bfqq->pos_root = NULL;
}
- /* oom_bfqq does not participate in queue merging */
- if (bfqq == &bfqd->oom_bfqq)
- return;
-
/*
* bfqq cannot be merged any longer (see comments in
* bfq_setup_cooperator): no point in adding bfqq into the
@@ -807,14 +806,13 @@ bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq)
if (!bfqq->next_rq)
return;
+ if (bfq_rq_pos_tree_lookup(bfqd, &bfqq_group(bfqq)->rq_pos_tree,
+ blk_rq_pos(bfqq->next_rq), &parent, &p))
+ return;
+
bfqq->pos_root = &bfqq_group(bfqq)->rq_pos_tree;
- __bfqq = bfq_rq_pos_tree_lookup(bfqd, bfqq->pos_root,
- blk_rq_pos(bfqq->next_rq), &parent, &p);
- if (!__bfqq) {
- rb_link_node(&bfqq->pos_node, parent, p);
- rb_insert_color(&bfqq->pos_node, bfqq->pos_root);
- } else
- bfqq->pos_root = NULL;
+ rb_link_node(&bfqq->pos_node, parent, p);
+ rb_insert_color(&bfqq->pos_node, bfqq->pos_root);
}
/*
There are three cleanups in this patch: 1. The oom_bfqq is never inserted to tree, so return immediately for oom_bfqq before unnecessary NULL check of bfqq->pos_root. 2. Only set bfqq->pos_root after bfq_rq_pos_tree_lookup successes rather than set bfqq->pos_root unconditionally and reset to NULL if bfq_rq_pos_tree_lookup fails. 3. Remove unnecessary local variable __bfqq which is only used to check return value of bfq_rq_pos_tree_lookup. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> --- block/bfq-iosched.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)