aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0b280978f097..5c6dd7ed26a7 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4264,6 +4264,9 @@ static void css_free_work_fn(struct work_struct *work)
4264 struct cgroup_subsys_state *css = 4264 struct cgroup_subsys_state *css =
4265 container_of(work, struct cgroup_subsys_state, destroy_work); 4265 container_of(work, struct cgroup_subsys_state, destroy_work);
4266 4266
4267 if (css->parent)
4268 css_put(css->parent);
4269
4267 cgroup_dput(css->cgroup); 4270 cgroup_dput(css->cgroup);
4268} 4271}
4269 4272
@@ -4290,8 +4293,12 @@ static void init_cgroup_css(struct cgroup_subsys_state *css,
4290 css->ss = ss; 4293 css->ss = ss;
4291 css->flags = 0; 4294 css->flags = 0;
4292 css->id = NULL; 4295 css->id = NULL;
4293 if (cgrp == cgroup_dummy_top) 4296
4297 if (cgrp->parent)
4298 css->parent = cgroup_css(cgrp->parent, ss->subsys_id);
4299 else
4294 css->flags |= CSS_ROOT; 4300 css->flags |= CSS_ROOT;
4301
4295 BUG_ON(cgroup_css(cgrp, ss->subsys_id)); 4302 BUG_ON(cgroup_css(cgrp, ss->subsys_id));
4296 cgrp->subsys[ss->subsys_id] = css; 4303 cgrp->subsys[ss->subsys_id] = css;
4297} 4304}
@@ -4388,6 +4395,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4388 cgrp->dentry = dentry; 4395 cgrp->dentry = dentry;
4389 4396
4390 cgrp->parent = parent; 4397 cgrp->parent = parent;
4398 cgrp->dummy_css.parent = &parent->dummy_css;
4391 cgrp->root = parent->root; 4399 cgrp->root = parent->root;
4392 4400
4393 if (notify_on_release(parent)) 4401 if (notify_on_release(parent))
@@ -4436,9 +4444,13 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4436 list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children); 4444 list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children);
4437 root->number_of_cgroups++; 4445 root->number_of_cgroups++;
4438 4446
4439 /* each css holds a ref to the cgroup's dentry */ 4447 /* each css holds a ref to the cgroup's dentry and the parent css */
4440 for_each_root_subsys(root, ss) 4448 for_each_root_subsys(root, ss) {
4449 struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
4450
4441 dget(dentry); 4451 dget(dentry);
4452 percpu_ref_get(&css->parent->refcnt);
4453 }
4442 4454
4443 /* hold a ref to the parent's dentry */ 4455 /* hold a ref to the parent's dentry */
4444 dget(parent->dentry); 4456 dget(parent->dentry);