Merge remote-tracking branch 'asoc/topic/rcar' into asoc-next
[deliverable/linux.git] / kernel / cgroup.c
index e0aeb32415fff53a032803edbcf96ea30398b61d..8bd9cfdc70d7bc020dbc19a05813e2e49443b8e8 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/poll.h>
 #include <linux/flex_array.h> /* used in cgroup_attach_task */
 #include <linux/kthread.h>
+#include <linux/file.h>
 
 #include <linux/atomic.h>
 
@@ -2038,7 +2039,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
 
                /* @tsk either already exited or can't exit until the end */
                if (tsk->flags & PF_EXITING)
-                       continue;
+                       goto next;
 
                /* as per above, nr_threads may decrease, but not increase. */
                BUG_ON(i >= group_size);
@@ -2046,7 +2047,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
                ent.cgrp = task_cgroup_from_root(tsk, root);
                /* nothing to do if this task is already in the cgroup */
                if (ent.cgrp == cgrp)
-                       continue;
+                       goto next;
                /*
                 * saying GFP_ATOMIC has no effect here because we did prealloc
                 * earlier, but it's good form to communicate our expectations.
@@ -2054,7 +2055,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
                retval = flex_array_put(group, i, &ent, GFP_ATOMIC);
                BUG_ON(retval != 0);
                i++;
-
+       next:
                if (!threadgroup)
                        break;
        } while_each_thread(leader, tsk);
@@ -3187,11 +3188,9 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,
 
        WARN_ON_ONCE(!rcu_read_lock_held());
 
-       /* if first iteration, visit the leftmost descendant */
-       if (!pos) {
-               next = css_leftmost_descendant(root);
-               return next != root ? next : NULL;
-       }
+       /* if first iteration, visit leftmost descendant which may be @root */
+       if (!pos)
+               return css_leftmost_descendant(root);
 
        /* if we visited @root, we're done */
        if (pos == root)
@@ -4034,8 +4033,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
        struct cgroup_event *event;
        struct cgroup_subsys_state *cfile_css;
        unsigned int efd, cfd;
-       struct file *efile;
-       struct file *cfile;
+       struct fefile;
+       struct fcfile;
        char *endp;
        int ret;
 
@@ -4058,31 +4057,31 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
        init_waitqueue_func_entry(&event->wait, cgroup_event_wake);
        INIT_WORK(&event->remove, cgroup_event_remove);
 
-       efile = eventfd_fget(efd);
-       if (IS_ERR(efile)) {
-               ret = PTR_ERR(efile);
+       efile = fdget(efd);
+       if (!efile.file) {
+               ret = -EBADF;
                goto out_kfree;
        }
 
-       event->eventfd = eventfd_ctx_fileget(efile);
+       event->eventfd = eventfd_ctx_fileget(efile.file);
        if (IS_ERR(event->eventfd)) {
                ret = PTR_ERR(event->eventfd);
                goto out_put_efile;
        }
 
-       cfile = fget(cfd);
-       if (!cfile) {
+       cfile = fdget(cfd);
+       if (!cfile.file) {
                ret = -EBADF;
                goto out_put_eventfd;
        }
 
        /* the process need read permission on control file */
        /* 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)
                goto out_put_cfile;
 
-       event->cft = __file_cft(cfile);
+       event->cft = __file_cft(cfile.file);
        if (IS_ERR(event->cft)) {
                ret = PTR_ERR(event->cft);
                goto out_put_cfile;
@@ -4103,7 +4102,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
 
        ret = -EINVAL;
        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))
                ret = 0;
 
@@ -4121,25 +4120,25 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *dummy_css,
        if (ret)
                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);
        list_add(&event->list, &cgrp->event_list);
        spin_unlock(&cgrp->event_list_lock);
 
-       fput(cfile);
-       fput(efile);
+       fdput(cfile);
+       fdput(efile);
 
        return 0;
 
 out_put_css:
        css_put(event->css);
 out_put_cfile:
-       fput(cfile);
+       fdput(cfile);
 out_put_eventfd:
        eventfd_ctx_put(event->eventfd);
 out_put_efile:
-       fput(efile);
+       fdput(efile);
 out_kfree:
        kfree(event);
 
This page took 0.028162 seconds and 5 git commands to generate.