mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-06 05:06:29 +00:00
cgroup_do_mount(): massage calling conventions
pass it fs_context instead of fs_type/flags/root triple, have it return int instead of dentry and make it deal with setting fc->root. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
cf6299b1d0
commit
71d883c37e
@ -212,8 +212,7 @@ void cgroup_free_root(struct cgroup_root *root);
|
|||||||
void init_cgroup_root(struct cgroup_fs_context *ctx);
|
void init_cgroup_root(struct cgroup_fs_context *ctx);
|
||||||
int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
|
int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
|
||||||
int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
|
int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
|
||||||
struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
|
int cgroup_do_mount(struct fs_context *fc, unsigned long magic,
|
||||||
struct cgroup_root *root, unsigned long magic,
|
|
||||||
struct cgroup_namespace *ns);
|
struct cgroup_namespace *ns);
|
||||||
|
|
||||||
int cgroup_migrate_vet_dst(struct cgroup *dst_cgrp);
|
int cgroup_migrate_vet_dst(struct cgroup *dst_cgrp);
|
||||||
|
@ -1141,7 +1141,6 @@ int cgroup1_get_tree(struct fs_context *fc)
|
|||||||
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
|
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
|
||||||
struct cgroup_root *root;
|
struct cgroup_root *root;
|
||||||
struct cgroup_subsys *ss;
|
struct cgroup_subsys *ss;
|
||||||
struct dentry *dentry;
|
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
/* Check if the caller has permission to mount. */
|
/* Check if the caller has permission to mount. */
|
||||||
@ -1253,21 +1252,15 @@ int cgroup1_get_tree(struct fs_context *fc)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
dentry = cgroup_do_mount(&cgroup_fs_type, fc->sb_flags, root,
|
ret = cgroup_do_mount(fc, CGROUP_SUPER_MAGIC, ns);
|
||||||
CGROUP_SUPER_MAGIC, ns);
|
if (!ret && percpu_ref_is_dying(&root->cgrp.self.refcnt)) {
|
||||||
if (IS_ERR(dentry))
|
struct super_block *sb = fc->root->d_sb;
|
||||||
return PTR_ERR(dentry);
|
dput(fc->root);
|
||||||
|
|
||||||
if (percpu_ref_is_dying(&root->cgrp.self.refcnt)) {
|
|
||||||
struct super_block *sb = dentry->d_sb;
|
|
||||||
dput(dentry);
|
|
||||||
deactivate_locked_super(sb);
|
deactivate_locked_super(sb);
|
||||||
msleep(10);
|
msleep(10);
|
||||||
return restart_syscall();
|
return restart_syscall();
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
fc->root = dentry;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init cgroup1_wq_init(void)
|
static int __init cgroup1_wq_init(void)
|
||||||
|
@ -2036,43 +2036,48 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
|
int cgroup_do_mount(struct fs_context *fc, unsigned long magic,
|
||||||
struct cgroup_root *root, unsigned long magic,
|
struct cgroup_namespace *ns)
|
||||||
struct cgroup_namespace *ns)
|
|
||||||
{
|
{
|
||||||
struct dentry *dentry;
|
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
|
||||||
bool new_sb = false;
|
bool new_sb = false;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
dentry = kernfs_mount(fs_type, flags, root->kf_root, magic, &new_sb);
|
fc->root = kernfs_mount(fc->fs_type, fc->sb_flags, ctx->root->kf_root,
|
||||||
|
magic, &new_sb);
|
||||||
|
if (IS_ERR(fc->root))
|
||||||
|
ret = PTR_ERR(fc->root);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In non-init cgroup namespace, instead of root cgroup's dentry,
|
* In non-init cgroup namespace, instead of root cgroup's dentry,
|
||||||
* we return the dentry corresponding to the cgroupns->root_cgrp.
|
* we return the dentry corresponding to the cgroupns->root_cgrp.
|
||||||
*/
|
*/
|
||||||
if (!IS_ERR(dentry) && ns != &init_cgroup_ns) {
|
if (!ret && ns != &init_cgroup_ns) {
|
||||||
struct dentry *nsdentry;
|
struct dentry *nsdentry;
|
||||||
struct super_block *sb = dentry->d_sb;
|
struct super_block *sb = fc->root->d_sb;
|
||||||
struct cgroup *cgrp;
|
struct cgroup *cgrp;
|
||||||
|
|
||||||
mutex_lock(&cgroup_mutex);
|
mutex_lock(&cgroup_mutex);
|
||||||
spin_lock_irq(&css_set_lock);
|
spin_lock_irq(&css_set_lock);
|
||||||
|
|
||||||
cgrp = cset_cgroup_from_root(ns->root_cset, root);
|
cgrp = cset_cgroup_from_root(ns->root_cset, ctx->root);
|
||||||
|
|
||||||
spin_unlock_irq(&css_set_lock);
|
spin_unlock_irq(&css_set_lock);
|
||||||
mutex_unlock(&cgroup_mutex);
|
mutex_unlock(&cgroup_mutex);
|
||||||
|
|
||||||
nsdentry = kernfs_node_dentry(cgrp->kn, sb);
|
nsdentry = kernfs_node_dentry(cgrp->kn, sb);
|
||||||
dput(dentry);
|
dput(fc->root);
|
||||||
if (IS_ERR(nsdentry))
|
fc->root = nsdentry;
|
||||||
|
if (IS_ERR(nsdentry)) {
|
||||||
|
ret = PTR_ERR(nsdentry);
|
||||||
deactivate_locked_super(sb);
|
deactivate_locked_super(sb);
|
||||||
dentry = nsdentry;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!new_sb)
|
if (!new_sb)
|
||||||
cgroup_put(&root->cgrp);
|
cgroup_put(&ctx->root->cgrp);
|
||||||
|
|
||||||
return dentry;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2091,7 +2096,7 @@ static int cgroup_get_tree(struct fs_context *fc)
|
|||||||
{
|
{
|
||||||
struct cgroup_namespace *ns = current->nsproxy->cgroup_ns;
|
struct cgroup_namespace *ns = current->nsproxy->cgroup_ns;
|
||||||
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
|
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
|
||||||
struct dentry *root;
|
int ret;
|
||||||
|
|
||||||
/* Check if the caller has permission to mount. */
|
/* Check if the caller has permission to mount. */
|
||||||
if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
|
if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
|
||||||
@ -2101,14 +2106,10 @@ static int cgroup_get_tree(struct fs_context *fc)
|
|||||||
cgroup_get_live(&cgrp_dfl_root.cgrp);
|
cgroup_get_live(&cgrp_dfl_root.cgrp);
|
||||||
ctx->root = &cgrp_dfl_root;
|
ctx->root = &cgrp_dfl_root;
|
||||||
|
|
||||||
root = cgroup_do_mount(&cgroup2_fs_type, fc->sb_flags, &cgrp_dfl_root,
|
ret = cgroup_do_mount(fc, CGROUP2_SUPER_MAGIC, ns);
|
||||||
CGROUP2_SUPER_MAGIC, ns);
|
if (!ret)
|
||||||
if (IS_ERR(root))
|
apply_cgroup_root_flags(ctx->flags);
|
||||||
return PTR_ERR(root);
|
return ret;
|
||||||
|
|
||||||
apply_cgroup_root_flags(ctx->flags);
|
|
||||||
fc->root = root;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct fs_context_operations cgroup_fs_context_ops = {
|
static const struct fs_context_operations cgroup_fs_context_ops = {
|
||||||
|
Loading…
Reference in New Issue
Block a user