diff options
author | Li Zefan <lizefan@huawei.com> | 2013-01-24 01:30:22 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-01-24 15:05:17 -0500 |
commit | fe1c06ca7523baa668c1eaf1e1016fa64753c32e (patch) | |
tree | 25a86fc2be7a9c155bb490332696b4228964207d /kernel | |
parent | b5d646f5d5a135064232ff3a140a47a5b84bc911 (diff) |
cgroup: initialize cgrp->dentry before css_alloc()
With this change, we're guaranteed that cgroup_path() won't see NULL
cgrp->dentry, and thus we can remove the NULL check in it.
(Well, it's not strictly true, because dummptop.dentry is always NULL
but we already handle that separately.)
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 8da9048078c5..a04932281bc9 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1767,7 +1767,7 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) | |||
1767 | rcu_lockdep_assert(rcu_read_lock_held() || cgroup_lock_is_held(), | 1767 | rcu_lockdep_assert(rcu_read_lock_held() || cgroup_lock_is_held(), |
1768 | "cgroup_path() called without proper locking"); | 1768 | "cgroup_path() called without proper locking"); |
1769 | 1769 | ||
1770 | if (!dentry || cgrp == dummytop) { | 1770 | if (cgrp == dummytop) { |
1771 | /* | 1771 | /* |
1772 | * Inactive subsystems have no dentry for their root | 1772 | * Inactive subsystems have no dentry for their root |
1773 | * cgroup | 1773 | * cgroup |
@@ -4153,6 +4153,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4153 | 4153 | ||
4154 | init_cgroup_housekeeping(cgrp); | 4154 | init_cgroup_housekeeping(cgrp); |
4155 | 4155 | ||
4156 | dentry->d_fsdata = cgrp; | ||
4157 | cgrp->dentry = dentry; | ||
4158 | |||
4156 | cgrp->parent = parent; | 4159 | cgrp->parent = parent; |
4157 | cgrp->root = parent->root; | 4160 | cgrp->root = parent->root; |
4158 | cgrp->top_cgroup = parent->top_cgroup; | 4161 | cgrp->top_cgroup = parent->top_cgroup; |
@@ -4190,8 +4193,6 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4190 | lockdep_assert_held(&dentry->d_inode->i_mutex); | 4193 | lockdep_assert_held(&dentry->d_inode->i_mutex); |
4191 | 4194 | ||
4192 | /* allocation complete, commit to creation */ | 4195 | /* allocation complete, commit to creation */ |
4193 | dentry->d_fsdata = cgrp; | ||
4194 | cgrp->dentry = dentry; | ||
4195 | list_add_tail(&cgrp->allcg_node, &root->allcg_list); | 4196 | list_add_tail(&cgrp->allcg_node, &root->allcg_list); |
4196 | list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children); | 4197 | list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children); |
4197 | root->number_of_cgroups++; | 4198 | root->number_of_cgroups++; |