summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2019-01-17 02:25:51 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2019-02-28 03:29:32 -0500
commitcf6299b1d00555cd10dc30d95b300d7084128a2c (patch)
treef4cd581ee037732a736b70e1fffa220e012be512 /kernel
parente34a98d5b226b84a3ed6da93e7a92e65cc1c81ba (diff)
cgroup: stash cgroup_root reference into cgroup_fs_context
Note that this reference is *NOT* contributing to refcount of cgroup_root in question and is valid only until cgroup_do_mount() returns. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup/cgroup-internal.h3
-rw-r--r--kernel/cgroup/cgroup-v1.c4
-rw-r--r--kernel/cgroup/cgroup.c7
3 files changed, 10 insertions, 4 deletions
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index a7b5a41f170c..3c1613a7648c 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -41,6 +41,7 @@ extern void __init enable_debug_cgroup(void);
41 * The cgroup filesystem superblock creation/mount context. 41 * The cgroup filesystem superblock creation/mount context.
42 */ 42 */
43struct cgroup_fs_context { 43struct cgroup_fs_context {
44 struct cgroup_root *root;
44 unsigned int flags; /* CGRP_ROOT_* flags */ 45 unsigned int flags; /* CGRP_ROOT_* flags */
45 46
46 /* cgroup1 bits */ 47 /* cgroup1 bits */
@@ -208,7 +209,7 @@ int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
208 struct cgroup_namespace *ns); 209 struct cgroup_namespace *ns);
209 210
210void cgroup_free_root(struct cgroup_root *root); 211void cgroup_free_root(struct cgroup_root *root);
211void init_cgroup_root(struct cgroup_root *root, struct cgroup_fs_context *ctx); 212void init_cgroup_root(struct cgroup_fs_context *ctx);
212int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask); 213int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
213int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask); 214int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
214struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags, 215struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index 725e9f6fe80d..45a198c63d6e 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -1208,6 +1208,7 @@ int cgroup1_get_tree(struct fs_context *fc)
1208 if (root->flags ^ ctx->flags) 1208 if (root->flags ^ ctx->flags)
1209 pr_warn("new mount options do not match the existing superblock, will be ignored\n"); 1209 pr_warn("new mount options do not match the existing superblock, will be ignored\n");
1210 1210
1211 ctx->root = root;
1211 ret = 0; 1212 ret = 0;
1212 goto out_unlock; 1213 goto out_unlock;
1213 } 1214 }
@@ -1234,7 +1235,8 @@ int cgroup1_get_tree(struct fs_context *fc)
1234 goto out_unlock; 1235 goto out_unlock;
1235 } 1236 }
1236 1237
1237 init_cgroup_root(root, ctx); 1238 ctx->root = root;
1239 init_cgroup_root(ctx);
1238 1240
1239 ret = cgroup_setup_root(root, ctx->subsys_mask); 1241 ret = cgroup_setup_root(root, ctx->subsys_mask);
1240 if (ret) 1242 if (ret)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index d0cddfbdf5cf..57f43f63363a 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1915,8 +1915,9 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
1915 INIT_WORK(&cgrp->release_agent_work, cgroup1_release_agent); 1915 INIT_WORK(&cgrp->release_agent_work, cgroup1_release_agent);
1916} 1916}
1917 1917
1918void init_cgroup_root(struct cgroup_root *root, struct cgroup_fs_context *ctx) 1918void init_cgroup_root(struct cgroup_fs_context *ctx)
1919{ 1919{
1920 struct cgroup_root *root = ctx->root;
1920 struct cgroup *cgrp = &root->cgrp; 1921 struct cgroup *cgrp = &root->cgrp;
1921 1922
1922 INIT_LIST_HEAD(&root->root_list); 1923 INIT_LIST_HEAD(&root->root_list);
@@ -2098,6 +2099,7 @@ static int cgroup_get_tree(struct fs_context *fc)
2098 2099
2099 cgrp_dfl_visible = true; 2100 cgrp_dfl_visible = true;
2100 cgroup_get_live(&cgrp_dfl_root.cgrp); 2101 cgroup_get_live(&cgrp_dfl_root.cgrp);
2102 ctx->root = &cgrp_dfl_root;
2101 2103
2102 root = cgroup_do_mount(&cgroup2_fs_type, fc->sb_flags, &cgrp_dfl_root, 2104 root = cgroup_do_mount(&cgroup2_fs_type, fc->sb_flags, &cgrp_dfl_root,
2103 CGROUP2_SUPER_MAGIC, ns); 2105 CGROUP2_SUPER_MAGIC, ns);
@@ -5374,7 +5376,8 @@ int __init cgroup_init_early(void)
5374 struct cgroup_subsys *ss; 5376 struct cgroup_subsys *ss;
5375 int i; 5377 int i;
5376 5378
5377 init_cgroup_root(&cgrp_dfl_root, &ctx); 5379 ctx.root = &cgrp_dfl_root;
5380 init_cgroup_root(&ctx);
5378 cgrp_dfl_root.cgrp.self.flags |= CSS_NO_REF; 5381 cgrp_dfl_root.cgrp.self.flags |= CSS_NO_REF;
5379 5382
5380 RCU_INIT_POINTER(init_task.cgroups, &init_css_set); 5383 RCU_INIT_POINTER(init_task.cgroups, &init_css_set);