]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - block/bfq-wf2q.c
block, bfq: add/remove entity weights correctly
[linux.git] / block / bfq-wf2q.c
index 4498c43245e2d4d4168d6bb133c65980db83345c..58cf38fcee058ff10a13e0c313f0c08e0867b7c6 100644 (file)
@@ -499,9 +499,6 @@ static void bfq_active_insert(struct bfq_service_tree *st,
        if (bfqq)
                list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list);
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
-       else /* bfq_group */
-               bfq_weights_tree_add(bfqd, entity, &bfqd->group_weights_tree);
-
        if (bfqg != bfqd->root_group)
                bfqg->active_entities++;
 #endif
@@ -601,10 +598,6 @@ static void bfq_active_extract(struct bfq_service_tree *st,
        if (bfqq)
                list_del(&bfqq->bfqq_list);
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
-       else /* bfq_group */
-               bfq_weights_tree_remove(bfqd, entity,
-                                       &bfqd->group_weights_tree);
-
        if (bfqg != bfqd->root_group)
                bfqg->active_entities--;
 #endif
@@ -799,7 +792,7 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st,
                if (prev_weight != new_weight) {
                        root = bfqq ? &bfqd->queue_weights_tree :
                                      &bfqd->group_weights_tree;
-                       bfq_weights_tree_remove(bfqd, entity, root);
+                       __bfq_weights_tree_remove(bfqd, entity, root);
                }
                entity->weight = new_weight;
                /*
@@ -971,7 +964,7 @@ static void bfq_update_fin_time_enqueue(struct bfq_entity *entity,
  * one of its children receives a new request.
  *
  * Basically, this function updates the timestamps of entity and
- * inserts entity into its active tree, ater possibly extracting it
+ * inserts entity into its active tree, after possibly extracting it
  * from its idle tree.
  */
 static void __bfq_activate_entity(struct bfq_entity *entity,
@@ -1015,6 +1008,16 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
                entity->on_st = true;
        }
 
+#ifdef BFQ_GROUP_IOSCHED_ENABLED
+       if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */
+               struct bfq_group *bfqg =
+                       container_of(entity, struct bfq_group, entity);
+
+               bfq_weights_tree_add(bfqg->bfqd, entity,
+                                    &bfqd->group_weights_tree);
+       }
+#endif
+
        bfq_update_fin_time_enqueue(entity, st, backshifted);
 }
 
@@ -1664,8 +1667,7 @@ void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq,
        bfqd->busy_queues--;
 
        if (!bfqq->dispatched)
-               bfq_weights_tree_remove(bfqd, &bfqq->entity,
-                                       &bfqd->queue_weights_tree);
+               bfq_weights_tree_remove(bfqd, bfqq);
 
        if (bfqq->wr_coeff > 1)
                bfqd->wr_busy_queues--;