This adds CFTYPE_ONLY_ON_VE_ROOT flag for control files. It will be used in later patch to create cgroup control file which will show up only on ve root cgroups.
https://jira.sw.ru/browse/PSBM-33401 Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com> --- include/linux/cgroup.h | 1 + kernel/cgroup.c | 59 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 7caa14d..816cbac 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -445,6 +445,7 @@ struct cgroup_map_cb { #define CFTYPE_NOT_ON_ROOT (1U << 1) /* don't create on root cg */ #define CFTYPE_INSANE (1U << 2) /* don't create if sane_behavior */ #define CFTYPE_VE_WRITABLE (1U << 15) /* allow write from CT */ +#define CFTYPE_ONLY_ON_VE_ROOT (1U << 16) /* only create on CT's root cg */ #define MAX_CFTYPE_NAME 64 diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 5ea44e1..9a39c26 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -1793,21 +1793,6 @@ static struct file_system_type cgroup_fs_type = { static struct kobject *cgroup_kobj; -#ifdef CONFIG_VE -void cgroup_mark_ve_root(struct ve_struct *ve) -{ - struct cgroup *cgrp; - struct cgroupfs_root *root; - - mutex_lock(&cgroup_mutex); - for_each_active_root(root) { - cgrp = task_cgroup_from_root(ve->init_task, root); - set_bit(CGRP_VE_ROOT, &cgrp->flags); - } - mutex_unlock(&cgroup_mutex); -} -#endif - /** * cgroup_path - generate the path of a cgroup * @cgrp: the cgroup in question @@ -2822,6 +2807,9 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, continue; if ((cft->flags & CFTYPE_ONLY_ON_ROOT) && cgrp->parent) continue; + if ((cft->flags & CFTYPE_ONLY_ON_VE_ROOT) && + !test_bit(CGRP_VE_ROOT, &cgrp->flags)) + continue; if (is_add) { err = cgroup_add_file(cgrp, subsys, cft); @@ -4217,6 +4205,47 @@ static void offline_css(struct cgroup_subsys *ss, struct cgroup *cgrp) cgrp->subsys[ss->subsys_id]->flags &= ~CSS_ONLINE; } +#ifdef CONFIG_VE +static void cgroup_add_ve_root_files(struct cgroup *cgrp, + struct cgroup_subsys *subsys, + struct cftype cfts[]) +{ + struct cftype *cft; + + if (!test_bit(CGRP_VE_ROOT, &cgrp->flags)) + return; + + mutex_lock(&cgrp->dentry->d_inode->i_mutex); + for (cft = cfts; cft->name[0] != '\0'; cft++) { + int err; + + if (!(cft->flags & CFTYPE_ONLY_ON_VE_ROOT)) + continue; + + err = cgroup_add_file(cgrp, subsys, cft); + if (err) + pr_warn("cgroup_add_ve_root_files: failed to add %s, err=%d\n", + cft->name, err); + } + mutex_unlock(&cgrp->dentry->d_inode->i_mutex); +} + +void cgroup_mark_ve_root(struct ve_struct *ve) +{ + struct cgroup *cgrp; + struct cgroupfs_root *root; + + mutex_lock(&cgroup_mutex); + for_each_active_root(root) { + cgrp = task_cgroup_from_root(ve->init_task, root); + set_bit(CGRP_VE_ROOT, &cgrp->flags); + cgroup_add_ve_root_files(cgrp, NULL, files); + } + mutex_unlock(&cgroup_mutex); +} + +#endif + /* * cgroup_create - create a cgroup * @parent: cgroup that will be parent of the new cgroup -- 2.10.2 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel