• Dmitry Monakhov's avatar
    bfq: fix blkio cgroup leakage v4 · 2de791ab
    Dmitry Monakhov authored
    Changes from v1:
        - update commit description with proper ref-accounting justification
    
    commit db37a34c ("block, bfq: get a ref to a group when adding it to a service tree")
    introduce leak forbfq_group and blkcg_gq objects because of get/put
    imbalance.
    In fact whole idea of original commit is wrong because bfq_group entity
    can not dissapear under us because it is referenced by child bfq_queue's
    entities from here:
     -> bfq_init_entity()
        ->bfqg_and_blkg_get(bfqg);
        ->entity->parent = bfqg->my_entity
    
     -> bfq_put_queue(bfqq)
        FINAL_PUT
        ->bfqg_and_blkg_put(bfqq_group(bfqq))
        ->kmem_cache_free(bfq_pool, bfqq);
    
    So parent entity can not disappear while child entity is in tree,
    and child entities already has proper protection.
    This patch revert commit db37a34c ("block, bfq: get a ref to a group when adding it to a service tree")
    
    bfq_group leak trace caused by bad commit:
    -> blkg_alloc
       -> bfq_pq_alloc
         -> bfqg_get (+1)
    ->bfq_activate_bfqq
      ->bf...
    2de791ab
bfq-cgroup.c 38.5 KB