aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-06-25 14:53:37 -0400
committerTejun Heo <tj@kernel.org>2013-06-25 14:53:37 -0400
commitfc76df706123602214da494ba98bccea83e2cfff (patch)
tree27ff818b65d9c2866ba1caee3c739ec9f9232337
parent30159ec7a9db7f3c91e2b27e66389c49302efd5c (diff)
cgroup: reserve ID 0 for dummy_root and 1 for unified hierarchy
Before 1a57423166 ("cgroup: make hierarchy_id use cyclic idr"), hierarchy IDs were allocated from 0. As the dummy hierarchy was always the one first initialized, it got assigned 0 and all other hierarchies from 1. The patch accidentally changed the minimum useable ID to 2. Let's restore ID 0 for dummy_root and while at it reserve 1 for unified hierarchy. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Cc: stable@vger.kernel.org
-rw-r--r--kernel/cgroup.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index cef688128fb8..f9c99abc38ab 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1425,14 +1425,15 @@ static void init_cgroup_root(struct cgroupfs_root *root)
1425 init_cgroup_housekeeping(cgrp); 1425 init_cgroup_housekeeping(cgrp);
1426} 1426}
1427 1427
1428static int cgroup_init_root_id(struct cgroupfs_root *root) 1428static int cgroup_init_root_id(struct cgroupfs_root *root, int start, int end)
1429{ 1429{
1430 int id; 1430 int id;
1431 1431
1432 lockdep_assert_held(&cgroup_mutex); 1432 lockdep_assert_held(&cgroup_mutex);
1433 lockdep_assert_held(&cgroup_root_mutex); 1433 lockdep_assert_held(&cgroup_root_mutex);
1434 1434
1435 id = idr_alloc_cyclic(&cgroup_hierarchy_idr, root, 2, 0, GFP_KERNEL); 1435 id = idr_alloc_cyclic(&cgroup_hierarchy_idr, root, start, end,
1436 GFP_KERNEL);
1436 if (id < 0) 1437 if (id < 0)
1437 return id; 1438 return id;
1438 1439
@@ -1635,7 +1636,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1635 if (ret) 1636 if (ret)
1636 goto unlock_drop; 1637 goto unlock_drop;
1637 1638
1638 ret = cgroup_init_root_id(root); 1639 /* ID 0 is reserved for dummy root, 1 for unified hierarchy */
1640 ret = cgroup_init_root_id(root, 2, 0);
1639 if (ret) 1641 if (ret)
1640 goto unlock_drop; 1642 goto unlock_drop;
1641 1643
@@ -4898,7 +4900,7 @@ int __init cgroup_init(void)
4898 key = css_set_hash(init_css_set.subsys); 4900 key = css_set_hash(init_css_set.subsys);
4899 hash_add(css_set_table, &init_css_set.hlist, key); 4901 hash_add(css_set_table, &init_css_set.hlist, key);
4900 4902
4901 BUG_ON(cgroup_init_root_id(&cgroup_dummy_root)); 4903 BUG_ON(cgroup_init_root_id(&cgroup_dummy_root, 0, 1));
4902 4904
4903 mutex_unlock(&cgroup_root_mutex); 4905 mutex_unlock(&cgroup_root_mutex);
4904 mutex_unlock(&cgroup_mutex); 4906 mutex_unlock(&cgroup_mutex);