[Devel] [PATCH RHEL7 COMMIT] ve/cgroup: add VE mark to each user cgroup name on mount

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jan 14 05:04:43 PST 2016


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.9.20
------>
commit 1867565c8c6df8c2a18e391d9e6d721cf29e251e
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date:   Thu Jan 14 17:04:43 2016 +0400

    ve/cgroup: add VE mark to each user cgroup name on mount
    
    Cgroups have global list of roots, which leads to cgroups transparency for all
    CTs.
    The simpliest way is to mark cgroup root with ve pointer and use it as a pair
    to cgroup name to test superblock on mount.
    
    https://jira.sw.ru/browse/PSBM-42573
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
    Reviewed-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 include/linux/cgroup.h |  7 ++++++-
 kernel/cgroup.c        | 15 ++++++++++++---
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index ed5e6ac..b59e122 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -301,7 +301,9 @@ enum {
 	CGRP_ROOT_NOPREFIX	= (1 << 1), /* mounted subsystems have no named prefix */
 	CGRP_ROOT_XATTR		= (1 << 2), /* supports extended attributes */
 };
-
+#ifdef CONFIG_VE
+struct ve_struct;
+#endif
 /*
  * A cgroupfs_root represents the root of a cgroup hierarchy, and may be
  * associated with a superblock to form an active hierarchy.  This is
@@ -348,6 +350,9 @@ struct cgroupfs_root {
 
 	/* The name for this hierarchy - may be empty */
 	char name[MAX_CGROUP_ROOT_NAMELEN];
+#ifdef CONFIG_VE
+	struct ve_struct *ve;
+#endif
 };
 
 /*
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 4268373..a80b8bf 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1479,7 +1479,10 @@ static int cgroup_test_super(struct super_block *sb, void *data)
 {
 	struct cgroup_sb_opts *opts = data;
 	struct cgroupfs_root *root = sb->s_fs_info;
-
+#ifdef CONFIG_VE
+	if (get_exec_env() != root->ve)
+		return 0;
+#endif
 	/* If we asked for a name then it must match */
 	if (opts->name && strcmp(opts->name, root->name))
 		return 0;
@@ -1666,12 +1669,18 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
 		mutex_lock(&inode->i_mutex);
 		mutex_lock(&cgroup_mutex);
 		mutex_lock(&cgroup_root_mutex);
-
+#ifdef CONFIG_VE
+		root->ve = get_exec_env();
+#endif
 		/* Check for name clashes with existing mounts */
 		ret = -EBUSY;
 		if (strlen(root->name))
 			for_each_active_root(existing_root)
-				if (!strcmp(existing_root->name, root->name))
+				if (!strcmp(existing_root->name, root->name)
+#ifdef CONFIG_VE
+				    && (root->ve == existing_root->ve)
+#endif
+				    )
 					goto unlock_drop;
 
 		/*


More information about the Devel mailing list