aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
authorArianna Avanzini <avanzini.arianna@gmail.com>2015-07-06 21:08:15 -0400
committerJens Axboe <axboe@fb.com>2015-07-07 09:48:51 -0400
commita322baad1003798312741b0cb97bd2c7511ccf61 (patch)
treea5ea63b7699e989d14b853fb1b691be4819386cb /block/blk-cgroup.c
parent0762b23d23c1f23beab91a3af0fa89749b75f03c (diff)
block/blk-cgroup.c: free per-blkcg data when freeing the blkcg
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: e48453c3 ("block, cgroup: implement policy-specific per-blkcg data") Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 9f97da52d006..5e2723f2c6a3 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -822,8 +822,13 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
822{ 822{
823 struct blkcg *blkcg = css_to_blkcg(css); 823 struct blkcg *blkcg = css_to_blkcg(css);
824 824
825 if (blkcg != &blkcg_root) 825 if (blkcg != &blkcg_root) {
826 int i;
827
828 for (i = 0; i < BLKCG_MAX_POLS; i++)
829 kfree(blkcg->pd[i]);
826 kfree(blkcg); 830 kfree(blkcg);
831 }
827} 832}
828 833
829static struct cgroup_subsys_state * 834static struct cgroup_subsys_state *
@@ -1162,8 +1167,6 @@ void blkcg_deactivate_policy(struct request_queue *q,
1162 1167
1163 kfree(blkg->pd[pol->plid]); 1168 kfree(blkg->pd[pol->plid]);
1164 blkg->pd[pol->plid] = NULL; 1169 blkg->pd[pol->plid] = NULL;
1165 kfree(blkg->blkcg->pd[pol->plid]);
1166 blkg->blkcg->pd[pol->plid] = NULL;
1167 1170
1168 spin_unlock(&blkg->blkcg->lock); 1171 spin_unlock(&blkg->blkcg->lock);
1169 } 1172 }