[Devel] [patch rh7 3/3] cgroups: Drop per-cgroup release_agent code
Cyrill Gorcunov
gorcunov at odin.com
Wed Apr 29 04:56:26 PDT 2015
It was introduced for cgroups virtualization but since we
use bindmounts, lets drop it and step back to native
per-root @release_agent_path.
Signed-off-by: Cyrill Gorcunov <gorcunov at odin.com>
CC: Vladimir Davydov <vdavydov at odin.com>
CC: Konstantin Khorenko <khorenko at odin.com>
CC: Pavel Emelyanov <xemul at odin.com>
CC: Andrey Vagin <avagin at odin.com>
---
include/linux/cgroup.h | 6 +++---
kernel/cgroup.c | 42 +++++++++++-------------------------------
2 files changed, 14 insertions(+), 34 deletions(-)
Index: linux-pcs7.git/include/linux/cgroup.h
===================================================================
--- linux-pcs7.git.orig/include/linux/cgroup.h
+++ linux-pcs7.git/include/linux/cgroup.h
@@ -236,9 +236,6 @@ struct cgroup {
struct cgroupfs_root *root;
- /* The path to use for release notifications. */
- char *release_agent;
-
/* Owner VE for fake cgroup hierarchy */
struct ve_struct *cgroup_ve;
struct list_head cgroup_ve_list;
@@ -364,6 +361,9 @@ struct cgroupfs_root {
/* IDs for cgroups in this hierarchy */
struct ida cgroup_ida;
+ /* The path to use for release notifications. */
+ char release_agent_path[PATH_MAX];
+
/* The name for this hierarchy - may be empty */
char name[MAX_CGROUP_ROOT_NAMELEN];
};
Index: linux-pcs7.git/kernel/cgroup.c
===================================================================
--- linux-pcs7.git.orig/kernel/cgroup.c
+++ linux-pcs7.git/kernel/cgroup.c
@@ -852,7 +852,6 @@ static void cgroup_free_fn(struct work_s
ss->css_free(cgrp);
cgrp->root->number_of_cgroups--;
- kfree(cgrp->release_agent);
mutex_unlock(&cgroup_mutex);
/*
@@ -1093,7 +1092,6 @@ static int rebind_subsystems(struct cgro
static int cgroup_show_options(struct seq_file *seq, struct dentry *dentry)
{
struct cgroupfs_root *root = dentry->d_sb->s_fs_info;
- struct cgroup *top_cgrp;
struct cgroup_subsys *ss;
mutex_lock(&cgroup_root_mutex);
@@ -1106,14 +1104,8 @@ static int cgroup_show_options(struct se
if (root->flags & CGRP_ROOT_XATTR)
seq_puts(seq, ",xattr");
- /* bindmount to attribute file? */
- if (!S_ISDIR(dentry->d_inode->i_mode))
- dentry = dentry->d_parent;
- top_cgrp = dentry->d_fsdata;
- /* release_agent is stored on top cgroup */
- top_cgrp = &top_cgrp->root->top_cgroup;
- if (top_cgrp->release_agent)
- seq_printf(seq, ",release_agent=%s", top_cgrp->release_agent);
+ if (strlen(root->release_agent_path))
+ seq_printf(seq, ",release_agent=%s", root->release_agent_path);
if (test_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->top_cgroup.flags))
seq_puts(seq, ",clone_children");
@@ -1388,11 +1380,8 @@ static int cgroup_remount(struct super_b
/* re-populate subsystem files */
cgroup_populate_dir(cgrp, false, added_mask);
- if (opts.release_agent) {
- kfree(cgrp->release_agent);
- cgrp->release_agent = opts.release_agent;
- opts.release_agent = NULL;
- }
+ if (opts.release_agent)
+ strcpy(root->release_agent_path, opts.release_agent);
out_unlock:
kfree(opts.release_agent);
kfree(opts.name);
@@ -1505,6 +1494,8 @@ static struct cgroupfs_root *cgroup_root
root->subsys_mask = opts->subsys_mask;
root->flags = opts->flags;
ida_init(&root->cgroup_ida);
+ if (opts->release_agent)
+ strcpy(root->release_agent_path, opts->release_agent);
if (opts->name)
strcpy(root->name, opts->name);
if (opts->cpuset_clone_children)
@@ -1702,9 +1693,7 @@ static struct dentry *cgroup_mount(struc
BUG_ON(!list_empty(&root_cgrp->children));
BUG_ON(root->number_of_cgroups != 1);
- root_cgrp->release_agent = opts.release_agent;
root_cgrp->cgroup_ve = get_exec_env();
- opts.release_agent = NULL;
cred = override_creds(&init_cred);
cgroup_populate_dir(root_cgrp, true, root->subsys_mask);
@@ -2250,23 +2239,16 @@ static int cgroup_procs_write(struct cgr
static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft,
const char *buffer)
{
- char *release_agent;
+ BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
if (strlen(buffer) >= PATH_MAX)
return -EINVAL;
- release_agent = kstrdup(buffer, GFP_KERNEL);
- if (!release_agent)
- return -ENOMEM;
-
- if (!cgroup_lock_live_group(cgrp)) {
- kfree(release_agent);
+ if (!cgroup_lock_live_group(cgrp))
return -ENODEV;
- }
mutex_lock(&cgroup_root_mutex);
- kfree(cgrp->release_agent);
- cgrp->release_agent = release_agent;
+ strcpy(cgrp->root->release_agent_path, buffer);
mutex_unlock(&cgroup_root_mutex);
mutex_unlock(&cgroup_mutex);
return 0;
@@ -2277,8 +2259,7 @@ static int cgroup_release_agent_show(str
{
if (!cgroup_lock_live_group(cgrp))
return -ENODEV;
- if (cgrp->release_agent)
- seq_puts(seq, cgrp->release_agent);
+ seq_puts(seq, cgrp->root->release_agent_path);
seq_putc(seq, '\n');
mutex_unlock(&cgroup_mutex);
return 0;
@@ -5127,13 +5108,12 @@ static void cgroup_release_agent(struct
release_list);
list_del_init(&cgrp->release_list);
raw_spin_unlock(&release_list_lock);
-
pathbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!pathbuf)
goto continue_free;
if (cgroup_path(cgrp, pathbuf, PAGE_SIZE) < 0)
goto continue_free;
- agentbuf = kstrdup(cgrp->root->top_cgroup.release_agent, GFP_KERNEL);
+ agentbuf = kstrdup(cgrp->root->release_agent_path, GFP_KERNEL);
if (!agentbuf)
goto continue_free;
More information about the Devel
mailing list