Skip to content

Commit

Permalink
block/blk-cgroup.c: free per-blkcg data when freeing the blkcg
Browse files Browse the repository at this point in the history
Currently, per-blkcg data is freed each time a policy is deactivated,
that is also upon scheduler switch. However, when switching from a
scheduler implementing a policy which requires per-blkcg data to
another one, that same policy might be active on other devices, and
therefore those same per-blkcg data could be still in use.
This commit lets per-blkcg data be freed when the blkcg is freed
instead of on policy deactivation.

Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
Reported-and-tested-by: Michael Kaminsky <kaminsky@cs.cmu.edu>
Fixes: e48453c ("block, cgroup: implement policy-specific per-blkcg data")
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Arianna Avanzini authored and Jens Axboe committed Jul 7, 2015
1 parent 0762b23 commit a322baa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,13 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
{
struct blkcg *blkcg = css_to_blkcg(css);

if (blkcg != &blkcg_root)
if (blkcg != &blkcg_root) {
int i;

for (i = 0; i < BLKCG_MAX_POLS; i++)
kfree(blkcg->pd[i]);
kfree(blkcg);
}
}

static struct cgroup_subsys_state *
Expand Down Expand Up @@ -1162,8 +1167,6 @@ void blkcg_deactivate_policy(struct request_queue *q,

kfree(blkg->pd[pol->plid]);
blkg->pd[pol->plid] = NULL;
kfree(blkg->blkcg->pd[pol->plid]);
blkg->blkcg->pd[pol->plid] = NULL;

spin_unlock(&blkg->blkcg->lock);
}
Expand Down

0 comments on commit a322baa

Please sign in to comment.