aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-26 18:40:56 -0400
committerTejun Heo <tj@kernel.org>2013-08-26 18:40:56 -0400
commit7c918cbbd829669bf70ffcc45962d5d992942243 (patch)
tree32103bb699a0a70e8b81fdbdbad1bdb3c0cf2b25
parent7941cb027dccedec3c047271554ddcf4be2e0697 (diff)
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>
-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,
4041{ 4041{
4042 struct cgroup *cgrp = dummy_css->cgroup; 4042 struct cgroup *cgrp = dummy_css->cgroup;
4043 struct cgroup_event *event; 4043 struct cgroup_event *event;
4044 struct cgroup *cgrp_cfile; 4044 struct cgroup_subsys_state *cfile_css;
4045 unsigned int efd, cfd; 4045 unsigned int efd, cfd;
4046 struct file *efile; 4046 struct file *efile;
4047 struct file *cfile; 4047 struct file *cfile;
@@ -4103,7 +4103,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
4103 } 4103 }
4104 4104
4105 /* 4105 /*
4106 * Determine the css of @cfile and associate @event with it. 4106 * Determine the css of @cfile, verify it belongs to the same
4107 * cgroup as cgroup.event_control, and associate @event with it.
4107 * Remaining events are automatically removed on cgroup destruction 4108 * Remaining events are automatically removed on cgroup destruction
4108 * but the removal is asynchronous, so take an extra ref. 4109 * but the removal is asynchronous, so take an extra ref.
4109 */ 4110 */
@@ -4111,23 +4112,14 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
4111 4112
4112 ret = -EINVAL; 4113 ret = -EINVAL;
4113 event->css = cgroup_css(cgrp, event->cft->ss); 4114 event->css = cgroup_css(cgrp, event->cft->ss);
4114 if (event->css && css_tryget(event->css)) 4115 cfile_css = css_from_dir(cfile->f_dentry->d_parent, event->cft->ss);
4116 if (event->css && event->css == cfile_css && css_tryget(event->css))
4115 ret = 0; 4117 ret = 0;
4116 4118
4117 rcu_read_unlock(); 4119 rcu_read_unlock();
4118 if (ret) 4120 if (ret)
4119 goto out_put_cfile; 4121 goto out_put_cfile;
4120 4122
4121 /*
4122 * The file to be monitored must be in the same cgroup as
4123 * cgroup.event_control is.
4124 */
4125 cgrp_cfile = __d_cgrp(cfile->f_dentry->d_parent);
4126 if (cgrp_cfile != cgrp) {
4127 ret = -EINVAL;
4128 goto out_put_css;
4129 }
4130
4131 if (!event->cft->register_event || !event->cft->unregister_event) { 4123 if (!event->cft->register_event || !event->cft->unregister_event) {
4132 ret = -EINVAL; 4124 ret = -EINVAL;
4133 goto out_put_css; 4125 goto out_put_css;