diff options
Diffstat (limited to 'kernel/cgroup/cgroup.c')
-rw-r--r-- | kernel/cgroup/cgroup.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 300b0c416341..753afbca549f 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
@@ -2201,8 +2201,7 @@ static int cgroup_init_fs_context(struct fs_context *fc) | |||
2201 | fc->ops = &cgroup_fs_context_ops; | 2201 | fc->ops = &cgroup_fs_context_ops; |
2202 | else | 2202 | else |
2203 | fc->ops = &cgroup1_fs_context_ops; | 2203 | fc->ops = &cgroup1_fs_context_ops; |
2204 | if (fc->user_ns) | 2204 | put_user_ns(fc->user_ns); |
2205 | put_user_ns(fc->user_ns); | ||
2206 | fc->user_ns = get_user_ns(ctx->ns->user_ns); | 2205 | fc->user_ns = get_user_ns(ctx->ns->user_ns); |
2207 | fc->global = true; | 2206 | fc->global = true; |
2208 | return 0; | 2207 | return 0; |
@@ -2243,6 +2242,50 @@ static struct file_system_type cgroup2_fs_type = { | |||
2243 | .fs_flags = FS_USERNS_MOUNT, | 2242 | .fs_flags = FS_USERNS_MOUNT, |
2244 | }; | 2243 | }; |
2245 | 2244 | ||
2245 | #ifdef CONFIG_CPUSETS | ||
2246 | static const struct fs_context_operations cpuset_fs_context_ops = { | ||
2247 | .get_tree = cgroup1_get_tree, | ||
2248 | .free = cgroup_fs_context_free, | ||
2249 | }; | ||
2250 | |||
2251 | /* | ||
2252 | * This is ugly, but preserves the userspace API for existing cpuset | ||
2253 | * users. If someone tries to mount the "cpuset" filesystem, we | ||
2254 | * silently switch it to mount "cgroup" instead | ||
2255 | */ | ||
2256 | static int cpuset_init_fs_context(struct fs_context *fc) | ||
2257 | { | ||
2258 | char *agent = kstrdup("/sbin/cpuset_release_agent", GFP_USER); | ||
2259 | struct cgroup_fs_context *ctx; | ||
2260 | int err; | ||
2261 | |||
2262 | err = cgroup_init_fs_context(fc); | ||
2263 | if (err) { | ||
2264 | kfree(agent); | ||
2265 | return err; | ||
2266 | } | ||
2267 | |||
2268 | fc->ops = &cpuset_fs_context_ops; | ||
2269 | |||
2270 | ctx = cgroup_fc2context(fc); | ||
2271 | ctx->subsys_mask = 1 << cpuset_cgrp_id; | ||
2272 | ctx->flags |= CGRP_ROOT_NOPREFIX; | ||
2273 | ctx->release_agent = agent; | ||
2274 | |||
2275 | get_filesystem(&cgroup_fs_type); | ||
2276 | put_filesystem(fc->fs_type); | ||
2277 | fc->fs_type = &cgroup_fs_type; | ||
2278 | |||
2279 | return 0; | ||
2280 | } | ||
2281 | |||
2282 | static struct file_system_type cpuset_fs_type = { | ||
2283 | .name = "cpuset", | ||
2284 | .init_fs_context = cpuset_init_fs_context, | ||
2285 | .fs_flags = FS_USERNS_MOUNT, | ||
2286 | }; | ||
2287 | #endif | ||
2288 | |||
2246 | int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen, | 2289 | int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen, |
2247 | struct cgroup_namespace *ns) | 2290 | struct cgroup_namespace *ns) |
2248 | { | 2291 | { |
@@ -5761,6 +5804,9 @@ int __init cgroup_init(void) | |||
5761 | WARN_ON(register_filesystem(&cgroup_fs_type)); | 5804 | WARN_ON(register_filesystem(&cgroup_fs_type)); |
5762 | WARN_ON(register_filesystem(&cgroup2_fs_type)); | 5805 | WARN_ON(register_filesystem(&cgroup2_fs_type)); |
5763 | WARN_ON(!proc_create_single("cgroups", 0, NULL, proc_cgroupstats_show)); | 5806 | WARN_ON(!proc_create_single("cgroups", 0, NULL, proc_cgroupstats_show)); |
5807 | #ifdef CONFIG_CPUSETS | ||
5808 | WARN_ON(register_filesystem(&cpuset_fs_type)); | ||
5809 | #endif | ||
5764 | 5810 | ||
5765 | return 0; | 5811 | return 0; |
5766 | } | 5812 | } |