diff options
author | Zefan Li <lizefan@huawei.com> | 2014-09-20 02:49:10 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-09-20 13:09:35 -0400 |
commit | 0c7bf3e8cab7900e17ce7f97104c39927d835469 (patch) | |
tree | d2d21b9687e7ef63fe87f2bfc772367dfaa6f239 /kernel/cgroup.c | |
parent | 3e2cd91ab92665148616a80dc0745c499d2746a7 (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.c | 11 |
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, | |||
1694 | struct dentry *dentry; | 1694 | struct dentry *dentry; |
1695 | int ret; | 1695 | int ret; |
1696 | int i; | 1696 | int i; |
1697 | bool new_sb; | ||
1698 | 1697 | ||
1699 | /* | 1698 | /* |
1700 | * The first time anyone tries to mount a cgroup, enable the list | 1699 | * 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, | |||
1785 | * path is super cold. Let's just sleep a bit and retry. | 1784 | * path is super cold. Let's just sleep a bit and retry. |
1786 | */ | 1785 | */ |
1787 | pinned_sb = kernfs_pin_sb(root->kf_root, NULL); | 1786 | pinned_sb = kernfs_pin_sb(root->kf_root, NULL); |
1788 | if (IS_ERR(pinned_sb) || | 1787 | if (IS_ERR_OR_NULL(pinned_sb) || |
1789 | !percpu_ref_tryget_live(&root->cgrp.self.refcnt)) { | 1788 | !percpu_ref_tryget_live(&root->cgrp.self.refcnt)) { |
1790 | mutex_unlock(&cgroup_mutex); | 1789 | mutex_unlock(&cgroup_mutex); |
1791 | if (!IS_ERR_OR_NULL(pinned_sb)) | 1790 | if (!IS_ERR_OR_NULL(pinned_sb)) |
@@ -1831,18 +1830,16 @@ out_free: | |||
1831 | return ERR_PTR(ret); | 1830 | return ERR_PTR(ret); |
1832 | 1831 | ||
1833 | dentry = kernfs_mount(fs_type, flags, root->kf_root, | 1832 | dentry = kernfs_mount(fs_type, flags, root->kf_root, |
1834 | CGROUP_SUPER_MAGIC, &new_sb); | 1833 | CGROUP_SUPER_MAGIC, NULL); |
1835 | if (IS_ERR(dentry) || !new_sb) | 1834 | if (IS_ERR(dentry) || pinned_sb) |
1836 | cgroup_put(&root->cgrp); | 1835 | cgroup_put(&root->cgrp); |
1837 | 1836 | ||
1838 | /* | 1837 | /* |
1839 | * If @pinned_sb, we're reusing an existing root and holding an | 1838 | * If @pinned_sb, we're reusing an existing root and holding an |
1840 | * extra ref on its sb. Mount is complete. Put the extra ref. | 1839 | * extra ref on its sb. Mount is complete. Put the extra ref. |
1841 | */ | 1840 | */ |
1842 | if (pinned_sb) { | 1841 | if (pinned_sb) |
1843 | WARN_ON(new_sb); | ||
1844 | deactivate_super(pinned_sb); | 1842 | deactivate_super(pinned_sb); |
1845 | } | ||
1846 | 1843 | ||
1847 | return dentry; | 1844 | return dentry; |
1848 | } | 1845 | } |