diff options
author | Zefan Li <lizefan@huawei.com> | 2014-09-26 00:03:25 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-09-26 00:16:23 -0400 |
commit | e756c7b698604f11a979f2781d06eb7b80aba363 (patch) | |
tree | d9deebb021eb70e509f0c44b4094bc18509ea036 /kernel/cgroup.c | |
parent | 0c7bf3e8cab7900e17ce7f97104c39927d835469 (diff) |
Revert "cgroup: remove redundant variable in cgroup_mount()"
This reverts commit 0c7bf3e8cab7900e17ce7f97104c39927d835469.
If there are child cgroups in the cgroupfs and then we umount it,
the superblock will be destroyed but the cgroup_root will be kept
around. When we mount it again, cgroup_mount() will find this
cgroup_root and allocate a new sb for it.
So with this commit we will be trapped in a dead loop in the case
described above, because kernfs_pin_sb() keeps returning NULL.
Currently I don't see how we can avoid using both pinned_sb and
new_sb, so just revert it.
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Reported-by: Andrey Wagin <avagin@gmail.com>
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, 7 insertions, 4 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 5eb20cd1709c..f873c4681316 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1694,6 +1694,7 @@ 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; | ||
1697 | 1698 | ||
1698 | /* | 1699 | /* |
1699 | * The first time anyone tries to mount a cgroup, enable the list | 1700 | * The first time anyone tries to mount a cgroup, enable the list |
@@ -1784,7 +1785,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
1784 | * path is super cold. Let's just sleep a bit and retry. | 1785 | * path is super cold. Let's just sleep a bit and retry. |
1785 | */ | 1786 | */ |
1786 | pinned_sb = kernfs_pin_sb(root->kf_root, NULL); | 1787 | pinned_sb = kernfs_pin_sb(root->kf_root, NULL); |
1787 | if (IS_ERR_OR_NULL(pinned_sb) || | 1788 | if (IS_ERR(pinned_sb) || |
1788 | !percpu_ref_tryget_live(&root->cgrp.self.refcnt)) { | 1789 | !percpu_ref_tryget_live(&root->cgrp.self.refcnt)) { |
1789 | mutex_unlock(&cgroup_mutex); | 1790 | mutex_unlock(&cgroup_mutex); |
1790 | if (!IS_ERR_OR_NULL(pinned_sb)) | 1791 | if (!IS_ERR_OR_NULL(pinned_sb)) |
@@ -1830,16 +1831,18 @@ out_free: | |||
1830 | return ERR_PTR(ret); | 1831 | return ERR_PTR(ret); |
1831 | 1832 | ||
1832 | dentry = kernfs_mount(fs_type, flags, root->kf_root, | 1833 | dentry = kernfs_mount(fs_type, flags, root->kf_root, |
1833 | CGROUP_SUPER_MAGIC, NULL); | 1834 | CGROUP_SUPER_MAGIC, &new_sb); |
1834 | if (IS_ERR(dentry) || pinned_sb) | 1835 | if (IS_ERR(dentry) || !new_sb) |
1835 | cgroup_put(&root->cgrp); | 1836 | cgroup_put(&root->cgrp); |
1836 | 1837 | ||
1837 | /* | 1838 | /* |
1838 | * If @pinned_sb, we're reusing an existing root and holding an | 1839 | * If @pinned_sb, we're reusing an existing root and holding an |
1839 | * extra ref on its sb. Mount is complete. Put the extra ref. | 1840 | * extra ref on its sb. Mount is complete. Put the extra ref. |
1840 | */ | 1841 | */ |
1841 | if (pinned_sb) | 1842 | if (pinned_sb) { |
1843 | WARN_ON(new_sb); | ||
1842 | deactivate_super(pinned_sb); | 1844 | deactivate_super(pinned_sb); |
1845 | } | ||
1843 | 1846 | ||
1844 | return dentry; | 1847 | return dentry; |
1845 | } | 1848 | } |