summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-27 00:40:56 +0200
committerTejun Heo <tj@kernel.org>2013-08-27 00:40:56 +0200
commit7c918cbbd829669bf70ffcc45962d5d992942243 (patch)
tree32103bb699a0a70e8b81fdbdbad1bdb3c0cf2b25 /kernel/cgroup.c
parentcgroup: make cgroup_event hold onto cgroup_subsys_state instead of cgroup (diff)
downloadlinux-7c918cbbd829669bf70ffcc45962d5d992942243.tar.xz
linux-7c918cbbd829669bf70ffcc45962d5d992942243.zip
cgroup: make cgroup_write_event_control() use css_from_dir() instead of __d_cgrp()
cgroup_event will be moved to its only user - memcg. Replace __d_cgrp() usage with css_from_dir(), which is already exported. This also simplifies the code a bit. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 12237a291d88..e76698dd6c08 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4041,7 +4041,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
{
struct cgroup *cgrp = dummy_css->cgroup;
struct cgroup_event *event;
- struct cgroup *cgrp_cfile;
+ struct cgroup_subsys_state *cfile_css;
unsigned int efd, cfd;
struct file *efile;
struct file *cfile;
@@ -4103,7 +4103,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
}
/*
- * Determine the css of @cfile and associate @event with it.
+ * Determine the css of @cfile, verify it belongs to the same
+ * cgroup as cgroup.event_control, and associate @event with it.
* Remaining events are automatically removed on cgroup destruction
* but the removal is asynchronous, so take an extra ref.
*/
@@ -4111,23 +4112,14 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
ret = -EINVAL;
event->css = cgroup_css(cgrp, event->cft->ss);
- if (event->css && css_tryget(event->css))
+ cfile_css = css_from_dir(cfile->f_dentry->d_parent, event->cft->ss);
+ if (event->css && event->css == cfile_css && css_tryget(event->css))
ret = 0;
rcu_read_unlock();
if (ret)
goto out_put_cfile;
- /*
- * The file to be monitored must be in the same cgroup as
- * cgroup.event_control is.
- */
- cgrp_cfile = __d_cgrp(cfile->f_dentry->d_parent);
- if (cgrp_cfile != cgrp) {
- ret = -EINVAL;
- goto out_put_css;
- }
-
if (!event->cft->register_event || !event->cft->unregister_event) {
ret = -EINVAL;
goto out_put_css;