Skip to content

Commit cf6299b

Browse files
author
Al Viro
committed
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 <[email protected]>
1 parent e34a98d commit cf6299b

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

kernel/cgroup/cgroup-internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern void __init enable_debug_cgroup(void);
4141
* The cgroup filesystem superblock creation/mount context.
4242
*/
4343
struct cgroup_fs_context {
44+
struct cgroup_root *root;
4445
unsigned int flags; /* CGRP_ROOT_* flags */
4546

4647
/* cgroup1 bits */
@@ -208,7 +209,7 @@ int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
208209
struct cgroup_namespace *ns);
209210

210211
void cgroup_free_root(struct cgroup_root *root);
211-
void init_cgroup_root(struct cgroup_root *root, struct cgroup_fs_context *ctx);
212+
void init_cgroup_root(struct cgroup_fs_context *ctx);
212213
int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
213214
int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
214215
struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,

kernel/cgroup/cgroup-v1.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ int cgroup1_get_tree(struct fs_context *fc)
12081208
if (root->flags ^ ctx->flags)
12091209
pr_warn("new mount options do not match the existing superblock, will be ignored\n");
12101210

1211+
ctx->root = root;
12111212
ret = 0;
12121213
goto out_unlock;
12131214
}
@@ -1234,7 +1235,8 @@ int cgroup1_get_tree(struct fs_context *fc)
12341235
goto out_unlock;
12351236
}
12361237

1237-
init_cgroup_root(root, ctx);
1238+
ctx->root = root;
1239+
init_cgroup_root(ctx);
12381240

12391241
ret = cgroup_setup_root(root, ctx->subsys_mask);
12401242
if (ret)

kernel/cgroup/cgroup.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,8 +1915,9 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
19151915
INIT_WORK(&cgrp->release_agent_work, cgroup1_release_agent);
19161916
}
19171917

1918-
void init_cgroup_root(struct cgroup_root *root, struct cgroup_fs_context *ctx)
1918+
void init_cgroup_root(struct cgroup_fs_context *ctx)
19191919
{
1920+
struct cgroup_root *root = ctx->root;
19201921
struct cgroup *cgrp = &root->cgrp;
19211922

19221923
INIT_LIST_HEAD(&root->root_list);
@@ -2098,6 +2099,7 @@ static int cgroup_get_tree(struct fs_context *fc)
20982099

20992100
cgrp_dfl_visible = true;
21002101
cgroup_get_live(&cgrp_dfl_root.cgrp);
2102+
ctx->root = &cgrp_dfl_root;
21012103

21022104
root = cgroup_do_mount(&cgroup2_fs_type, fc->sb_flags, &cgrp_dfl_root,
21032105
CGROUP2_SUPER_MAGIC, ns);
@@ -5374,7 +5376,8 @@ int __init cgroup_init_early(void)
53745376
struct cgroup_subsys *ss;
53755377
int i;
53765378

5377-
init_cgroup_root(&cgrp_dfl_root, &ctx);
5379+
ctx.root = &cgrp_dfl_root;
5380+
init_cgroup_root(&ctx);
53785381
cgrp_dfl_root.cgrp.self.flags |= CSS_NO_REF;
53795382

53805383
RCU_INIT_POINTER(init_task.cgroups, &init_css_set);

0 commit comments

Comments
 (0)