summaryrefslogtreecommitdiff
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorZefan Li <lizefan@huawei.com>2014-09-20 14:49:10 +0800
committerTejun Heo <tj@kernel.org>2014-09-20 13:09:35 -0400
commit0c7bf3e8cab7900e17ce7f97104c39927d835469 (patch)
treed2d21b9687e7ef63fe87f2bfc772367dfaa6f239 /kernel/cgroup.c
parent3e2cd91ab92665148616a80dc0745c499d2746a7 (diff)
cgroup: remove redundant variable in cgroup_mount()
Both pinned_sb and new_sb indicate if a new superblock is needed, so we can just remove new_sb. Note now we must check if kernfs_tryget_sb() returns NULL, because when it returns NULL, kernfs_mount() may still re-use an existing superblock, which is just allocated by another concurent mount. Suggested-by: Tejun Heo <tj@kernel.org> Signed-off-by: Zefan Li <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index f873c4681316..5eb20cd1709c 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1694,7 +1694,6 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
struct dentry *dentry;
int ret;
int i;
- bool new_sb;
/*
* The first time anyone tries to mount a cgroup, enable the list
@@ -1785,7 +1784,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
* path is super cold. Let's just sleep a bit and retry.
*/
pinned_sb = kernfs_pin_sb(root->kf_root, NULL);
- if (IS_ERR(pinned_sb) ||
+ if (IS_ERR_OR_NULL(pinned_sb) ||
!percpu_ref_tryget_live(&root->cgrp.self.refcnt)) {
mutex_unlock(&cgroup_mutex);
if (!IS_ERR_OR_NULL(pinned_sb))
@@ -1831,18 +1830,16 @@ out_free:
return ERR_PTR(ret);
dentry = kernfs_mount(fs_type, flags, root->kf_root,
- CGROUP_SUPER_MAGIC, &new_sb);
- if (IS_ERR(dentry) || !new_sb)
+ CGROUP_SUPER_MAGIC, NULL);
+ if (IS_ERR(dentry) || pinned_sb)
cgroup_put(&root->cgrp);
/*
* If @pinned_sb, we're reusing an existing root and holding an
* extra ref on its sb. Mount is complete. Put the extra ref.
*/
- if (pinned_sb) {
- WARN_ON(new_sb);
+ if (pinned_sb)
deactivate_super(pinned_sb);
- }
return dentry;
}