Commit 4e10f3c9 authored by Al Viro's avatar Al Viro

Kill indirect include of file.h from eventfd.h, use fdget() in cgroup.c

kernel/cgroup.c is the only place in the tree that relies on eventfd.h
pulling file.h; move that include there.  Switch from eventfd_fget()/fput()
to fdget()/fdput(), while we are at it - eventfd_ctx_fileget() will fail
on non-eventfd descriptors just fine, no need to do that check twice...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent d0407903
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#define _LINUX_EVENTFD_H #define _LINUX_EVENTFD_H
#include <linux/fcntl.h> #include <linux/fcntl.h>
#include <linux/file.h>
#include <linux/wait.h> #include <linux/wait.h>
/* /*
...@@ -26,6 +25,8 @@ ...@@ -26,6 +25,8 @@
#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) #define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE) #define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
struct file;
#ifdef CONFIG_EVENTFD #ifdef CONFIG_EVENTFD
struct file *eventfd_file_create(unsigned int count, int flags); struct file *eventfd_file_create(unsigned int count, int flags);
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/flex_array.h> /* used in cgroup_attach_task */ #include <linux/flex_array.h> /* used in cgroup_attach_task */
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/file.h>
#include <linux/atomic.h> #include <linux/atomic.h>
...@@ -4034,8 +4035,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, ...@@ -4034,8 +4035,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
struct cgroup_event *event; struct cgroup_event *event;
struct cgroup_subsys_state *cfile_css; struct cgroup_subsys_state *cfile_css;
unsigned int efd, cfd; unsigned int efd, cfd;
struct file *efile; struct fd efile;
struct file *cfile; struct fd cfile;
char *endp; char *endp;
int ret; int ret;
...@@ -4058,31 +4059,31 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, ...@@ -4058,31 +4059,31 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
init_waitqueue_func_entry(&event->wait, cgroup_event_wake); init_waitqueue_func_entry(&event->wait, cgroup_event_wake);
INIT_WORK(&event->remove, cgroup_event_remove); INIT_WORK(&event->remove, cgroup_event_remove);
efile = eventfd_fget(efd); efile = fdget(efd);
if (IS_ERR(efile)) { if (!efile.file) {
ret = PTR_ERR(efile); ret = -EBADF;
goto out_kfree; goto out_kfree;
} }
event->eventfd = eventfd_ctx_fileget(efile); event->eventfd = eventfd_ctx_fileget(efile.file);
if (IS_ERR(event->eventfd)) { if (IS_ERR(event->eventfd)) {
ret = PTR_ERR(event->eventfd); ret = PTR_ERR(event->eventfd);
goto out_put_efile; goto out_put_efile;
} }
cfile = fget(cfd); cfile = fdget(cfd);
if (!cfile) { if (!cfile.file) {
ret = -EBADF; ret = -EBADF;
goto out_put_eventfd; goto out_put_eventfd;
} }
/* the process need read permission on control file */ /* the process need read permission on control file */
/* AV: shouldn't we check that it's been opened for read instead? */ /* AV: shouldn't we check that it's been opened for read instead? */
ret = inode_permission(file_inode(cfile), MAY_READ); ret = inode_permission(file_inode(cfile.file), MAY_READ);
if (ret < 0) if (ret < 0)
goto out_put_cfile; goto out_put_cfile;
event->cft = __file_cft(cfile); event->cft = __file_cft(cfile.file);
if (IS_ERR(event->cft)) { if (IS_ERR(event->cft)) {
ret = PTR_ERR(event->cft); ret = PTR_ERR(event->cft);
goto out_put_cfile; goto out_put_cfile;
...@@ -4103,7 +4104,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, ...@@ -4103,7 +4104,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
ret = -EINVAL; ret = -EINVAL;
event->css = cgroup_css(cgrp, event->cft->ss); event->css = cgroup_css(cgrp, event->cft->ss);
cfile_css = css_from_dir(cfile->f_dentry->d_parent, event->cft->ss); cfile_css = css_from_dir(cfile.file->f_dentry->d_parent, event->cft->ss);
if (event->css && event->css == cfile_css && css_tryget(event->css)) if (event->css && event->css == cfile_css && css_tryget(event->css))
ret = 0; ret = 0;
...@@ -4121,25 +4122,25 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css, ...@@ -4121,25 +4122,25 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
if (ret) if (ret)
goto out_put_css; goto out_put_css;
efile->f_op->poll(efile, &event->pt); efile.file->f_op->poll(efile.file, &event->pt);
spin_lock(&cgrp->event_list_lock); spin_lock(&cgrp->event_list_lock);
list_add(&event->list, &cgrp->event_list); list_add(&event->list, &cgrp->event_list);
spin_unlock(&cgrp->event_list_lock); spin_unlock(&cgrp->event_list_lock);
fput(cfile); fdput(cfile);
fput(efile); fdput(efile);
return 0; return 0;
out_put_css: out_put_css:
css_put(event->css); css_put(event->css);
out_put_cfile: out_put_cfile:
fput(cfile); fdput(cfile);
out_put_eventfd: out_put_eventfd:
eventfd_ctx_put(event->eventfd); eventfd_ctx_put(event->eventfd);
out_put_efile: out_put_efile:
fput(efile); fdput(efile);
out_kfree: out_kfree:
kfree(event); kfree(event);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment