diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-13 06:58:38 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-02-13 06:58:38 -0500 |
commit | 35585573055f37837eb752ee22eb5523682ca742 (patch) | |
tree | 6cf006b6409e6256ca4d3a81eb5701cde931a324 | |
parent | d3ba07c3aa9ae3e03329b0a7f1a067c0647aa2af (diff) |
cgroup: drop CGRP_ROOT_SUBSYS_BOUND
Before kernfs conversion, due to the way super_block lookup works,
cgroup roots were created and made visible before being fully
initialized. This in turn required a special flag to mark that the
root hasn't been fully initialized so that the destruction path can
tell fully bound ones from half initialized.
That flag is CGRP_ROOT_SUBSYS_BOUND and no longer necessary after the
kernfs conversion as the lookup and creation of new root are atomic
w.r.t. cgroup_mutex. This patch removes the flag and passes the
requests subsystem mask to cgroup_setup_root() so that it can set the
respective mask bits as subsystems are bound.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
-rw-r--r-- | include/linux/cgroup.h | 2 | ||||
-rw-r--r-- | kernel/cgroup.c | 28 |
2 files changed, 4 insertions, 26 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 5f669ca0ee36..e2ffcdc26cb7 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -267,8 +267,6 @@ enum { | |||
267 | 267 | ||
268 | /* mount options live below bit 16 */ | 268 | /* mount options live below bit 16 */ |
269 | CGRP_ROOT_OPTION_MASK = (1 << 16) - 1, | 269 | CGRP_ROOT_OPTION_MASK = (1 << 16) - 1, |
270 | |||
271 | CGRP_ROOT_SUBSYS_BOUND = (1 << 16), /* subsystems finished binding */ | ||
272 | }; | 270 | }; |
273 | 271 | ||
274 | /* | 272 | /* |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 079c478a4735..878cd1810ad1 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -733,7 +733,6 @@ static void cgroup_destroy_root(struct cgroupfs_root *root) | |||
733 | { | 733 | { |
734 | struct cgroup *cgrp = &root->top_cgroup; | 734 | struct cgroup *cgrp = &root->top_cgroup; |
735 | struct cgrp_cset_link *link, *tmp_link; | 735 | struct cgrp_cset_link *link, *tmp_link; |
736 | int ret; | ||
737 | 736 | ||
738 | mutex_lock(&cgroup_tree_mutex); | 737 | mutex_lock(&cgroup_tree_mutex); |
739 | mutex_lock(&cgroup_mutex); | 738 | mutex_lock(&cgroup_mutex); |
@@ -742,11 +741,7 @@ static void cgroup_destroy_root(struct cgroupfs_root *root) | |||
742 | BUG_ON(!list_empty(&cgrp->children)); | 741 | BUG_ON(!list_empty(&cgrp->children)); |
743 | 742 | ||
744 | /* Rebind all subsystems back to the default hierarchy */ | 743 | /* Rebind all subsystems back to the default hierarchy */ |
745 | if (root->flags & CGRP_ROOT_SUBSYS_BOUND) { | 744 | WARN_ON(rebind_subsystems(root, 0, root->subsys_mask)); |
746 | ret = rebind_subsystems(root, 0, root->subsys_mask); | ||
747 | /* Shouldn't be able to fail ... */ | ||
748 | BUG_ON(ret); | ||
749 | } | ||
750 | 745 | ||
751 | /* | 746 | /* |
752 | * Release all the links from cset_links to this hierarchy's | 747 | * Release all the links from cset_links to this hierarchy's |
@@ -1055,13 +1050,7 @@ static int rebind_subsystems(struct cgroupfs_root *root, | |||
1055 | } | 1050 | } |
1056 | } | 1051 | } |
1057 | 1052 | ||
1058 | /* | ||
1059 | * Mark @root has finished binding subsystems. @root->subsys_mask | ||
1060 | * now matches the bound subsystems. | ||
1061 | */ | ||
1062 | root->flags |= CGRP_ROOT_SUBSYS_BOUND; | ||
1063 | kernfs_activate(cgrp->kn); | 1053 | kernfs_activate(cgrp->kn); |
1064 | |||
1065 | return 0; | 1054 | return 0; |
1066 | } | 1055 | } |
1067 | 1056 | ||
@@ -1353,15 +1342,6 @@ static struct cgroupfs_root *cgroup_root_from_opts(struct cgroup_sb_opts *opts) | |||
1353 | 1342 | ||
1354 | init_cgroup_root(root); | 1343 | init_cgroup_root(root); |
1355 | 1344 | ||
1356 | /* | ||
1357 | * We need to set @root->subsys_mask now so that @root can be | ||
1358 | * matched by cgroup_test_super() before it finishes | ||
1359 | * initialization; otherwise, competing mounts with the same | ||
1360 | * options may try to bind the same subsystems instead of waiting | ||
1361 | * for the first one leading to unexpected mount errors. | ||
1362 | * SUBSYS_BOUND will be set once actual binding is complete. | ||
1363 | */ | ||
1364 | root->subsys_mask = opts->subsys_mask; | ||
1365 | root->flags = opts->flags; | 1345 | root->flags = opts->flags; |
1366 | if (opts->release_agent) | 1346 | if (opts->release_agent) |
1367 | strcpy(root->release_agent_path, opts->release_agent); | 1347 | strcpy(root->release_agent_path, opts->release_agent); |
@@ -1372,7 +1352,7 @@ static struct cgroupfs_root *cgroup_root_from_opts(struct cgroup_sb_opts *opts) | |||
1372 | return root; | 1352 | return root; |
1373 | } | 1353 | } |
1374 | 1354 | ||
1375 | static int cgroup_setup_root(struct cgroupfs_root *root) | 1355 | static int cgroup_setup_root(struct cgroupfs_root *root, unsigned long ss_mask) |
1376 | { | 1356 | { |
1377 | LIST_HEAD(tmp_links); | 1357 | LIST_HEAD(tmp_links); |
1378 | struct cgroup *root_cgrp = &root->top_cgroup; | 1358 | struct cgroup *root_cgrp = &root->top_cgroup; |
@@ -1415,7 +1395,7 @@ static int cgroup_setup_root(struct cgroupfs_root *root) | |||
1415 | if (ret) | 1395 | if (ret) |
1416 | goto destroy_root; | 1396 | goto destroy_root; |
1417 | 1397 | ||
1418 | ret = rebind_subsystems(root, root->subsys_mask, 0); | 1398 | ret = rebind_subsystems(root, ss_mask, 0); |
1419 | if (ret) | 1399 | if (ret) |
1420 | goto destroy_root; | 1400 | goto destroy_root; |
1421 | 1401 | ||
@@ -1532,7 +1512,7 @@ retry: | |||
1532 | goto out_unlock; | 1512 | goto out_unlock; |
1533 | } | 1513 | } |
1534 | 1514 | ||
1535 | ret = cgroup_setup_root(root); | 1515 | ret = cgroup_setup_root(root, opts.subsys_mask); |
1536 | if (ret) | 1516 | if (ret) |
1537 | cgroup_free_root(root); | 1517 | cgroup_free_root(root); |
1538 | 1518 | ||