[Devel] [PATCH RHEL7 COMMIT] cgroup: use cgroup_path_ve helper in cgroup_show_path

Vladimir Davydov vdavydov at virtuozzo.com
Mon Jun 20 10:07:48 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.16
------>
commit df0243406fc27e4af78ca6d9111a0bd30fea00a3
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Mon Jun 20 21:07:48 2016 +0400

    cgroup: use cgroup_path_ve helper in cgroup_show_path
    
    Presently, it basically duplicates the code used for mangling cgroup
    path shown inside ve, which is already present in cgroup_path_ve. Let's
    reuse it.
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 kernel/cgroup.c | 39 +++++++++------------------------------
 1 file changed, 9 insertions(+), 30 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 5c012f6e94e5..dd548853e2eb 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1373,41 +1373,20 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
 }
 
 #ifdef CONFIG_VE
-int cgroup_show_path(struct seq_file *m, struct dentry *dentry)
+static int cgroup_show_path(struct seq_file *m, struct dentry *dentry)
 {
-	char *buf;
+	struct cgroup *cgrp = __d_cgrp(dentry);
+	char *buf, *end;
 	size_t size = seq_get_buf(m, &buf);
-	int res = -1, err = 0;
-
-	if (size) {
-		char *p = dentry_path(dentry, buf, size);
-		if (!IS_ERR(p)) {
-			char *end;
-			if (!ve_is_super(get_exec_env())) {
-				while (*++p != '/') {
-					/*
-					 * Mangle one level when showing
-					 * cgroup mount source in container
-					 * e.g.: "/111" -> "/",
-					 * "/111/test.slice/test.scope" ->
-					 * "/test.slice/test.scope"
-					 */
-					if (*p == '\0') {
-						*--p = '/';
-						break;
-					}
-				}
-			}
-			end = mangle_path(buf, p, " \t\n\\");
-			if (end)
-				res = end - buf;
-		} else {
-			err = PTR_ERR(p);
-		}
+	int res = -1;
+
+	if (size > 0 && cgroup_path_ve(cgrp, buf, size) == 0) {
+		end = mangle_path(buf, buf, " \t\n\\");
+		res = end - buf;
 	}
 	seq_commit(m, res);
 
-	return err;
+	return 0;
 }
 #endif
 


More information about the Devel mailing list