]> Pileus Git - ~andy/linux/blobdiff - kernel/cgroup.c
Merge branch 'for-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
[~andy/linux] / kernel / cgroup.c
index b5f4989937f253676f283c9b5e959e465e4e77c7..e0aeb32415fff53a032803edbcf96ea30398b61d 100644 (file)
@@ -830,7 +830,6 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task,
  */
 
 static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
-static struct dentry *cgroup_lookup(struct inode *, struct dentry *, unsigned int);
 static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry);
 static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask);
 static const struct inode_operations cgroup_dir_inode_operations;
@@ -2650,7 +2649,7 @@ static const struct inode_operations cgroup_file_inode_operations = {
 };
 
 static const struct inode_operations cgroup_dir_inode_operations = {
-       .lookup = cgroup_lookup,
+       .lookup = simple_lookup,
        .mkdir = cgroup_mkdir,
        .rmdir = cgroup_rmdir,
        .rename = cgroup_rename,
@@ -2660,14 +2659,6 @@ static const struct inode_operations cgroup_dir_inode_operations = {
        .removexattr = cgroup_removexattr,
 };
 
-static struct dentry *cgroup_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
-{
-       if (dentry->d_name.len > NAME_MAX)
-               return ERR_PTR(-ENAMETOOLONG);
-       d_add(dentry, NULL);
-       return NULL;
-}
-
 /*
  * Check if a file is a control file
  */
@@ -4678,6 +4669,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
        struct dentry *d = cgrp->dentry;
        struct cgroup_event *event, *tmp;
        struct cgroup_subsys *ss;
+       struct cgroup *child;
        bool empty;
 
        lockdep_assert_held(&d->d_inode->i_mutex);
@@ -4688,11 +4680,27 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
         * @cgrp from being removed while __put_css_set() is in progress.
         */
        read_lock(&css_set_lock);
-       empty = list_empty(&cgrp->cset_links) && list_empty(&cgrp->children);
+       empty = list_empty(&cgrp->cset_links);
        read_unlock(&css_set_lock);
        if (!empty)
                return -EBUSY;
 
+       /*
+        * Make sure there's no live children.  We can't test ->children
+        * emptiness as dead children linger on it while being destroyed;
+        * otherwise, "rmdir parent/child parent" may fail with -EBUSY.
+        */
+       empty = true;
+       rcu_read_lock();
+       list_for_each_entry_rcu(child, &cgrp->children, sibling) {
+               empty = cgroup_is_dead(child);
+               if (!empty)
+                       break;
+       }
+       rcu_read_unlock();
+       if (!empty)
+               return -EBUSY;
+
        /*
         * Initiate massacre of all css's.  cgroup_destroy_css_killed()
         * will be invoked to perform the rest of destruction once the