static struct cftype cgroup_base_files[];
 
+static void cgroup_put(struct cgroup *cgrp);
 static void cgroup_destroy_css_killed(struct cgroup *cgrp);
 static int cgroup_destroy_locked(struct cgroup *cgrp);
 static int cgroup_addrm_files(struct cgroup *cgrp, struct cftype cfts[],
        return test_bit(CGRP_DEAD, &cgrp->flags);
 }
 
+struct cgroup_subsys_state *seq_css(struct seq_file *seq)
+{
+       struct cgroup_open_file *of = seq->private;
+       return of->cfe->css;
+}
+EXPORT_SYMBOL_GPL(seq_css);
+
 /**
  * cgroup_is_descendant - test ancestry
  * @cgrp: the cgroup to be tested
        return cset;
 }
 
+static void cgroup_get_root(struct cgroupfs_root *root)
+{
+       atomic_inc(&root->sb->s_active);
+}
+
+static void cgroup_put_root(struct cgroupfs_root *root)
+{
+       deactivate_super(root->sb);
+}
+
 /*
  * Return the cgroup for "task" from the given hierarchy. Must be
  * called with cgroup_mutex held.
        mutex_unlock(&cgroup_mutex);
 
        /*
-        * We get a ref to the parent's dentry, and put the ref when
-        * this cgroup is being freed, so it's guaranteed that the
-        * parent won't be destroyed before its children.
+        * We get a ref to the parent, and put the ref when this cgroup is
+        * being freed, so it's guaranteed that the parent won't be
+        * destroyed before its children.
         */
-       dput(cgrp->parent->dentry);
+       cgroup_put(cgrp->parent);
 
-       /*
-        * Drop the active superblock reference that we took when we
-        * created the cgroup. This will free cgrp->root, if we are
-        * holding the last reference to @sb.
-        */
-       deactivate_super(cgrp->root->sb);
+       /* put the root reference that we took when we created the cgroup */
+       cgroup_put_root(cgrp->root);
 
        cgroup_pidlist_destroy_all(cgrp);
 
        queue_work(cgroup_destroy_wq, &cgrp->destroy_work);
 }
 
+static void cgroup_get(struct cgroup *cgrp)
+{
+       dget(cgrp->dentry);
+}
+
 static void cgroup_diput(struct dentry *dentry, struct inode *inode)
 {
        /* is dentry a directory ? if so, kfree() associated cgroup */
        iput(inode);
 }
 
+static void cgroup_put(struct cgroup *cgrp)
+{
+       dput(cgrp->dentry);
+}
+
 static void remove_dir(struct dentry *d)
 {
        struct dentry *parent = dget(d->d_parent);
        struct cgroup_subsys *ss = cfts[0].ss;
        struct cgroup *root = &ss->root->top_cgroup;
        struct super_block *sb = ss->root->sb;
-       struct dentry *prev = NULL;
+       struct cgroup *prev = NULL;
        struct inode *inode;
        struct cgroup_subsys_state *css;
        u64 update_before;
                        continue;
 
                inode = cgrp->dentry->d_inode;
-               dget(cgrp->dentry);
-               dput(prev);
-               prev = cgrp->dentry;
+               cgroup_get(cgrp);
+               if (prev)
+                       cgroup_put(prev);
+               prev = cgrp;
 
                mutex_unlock(&cgroup_tree_mutex);
                mutex_lock(&inode->i_mutex);
                        break;
        }
        mutex_unlock(&cgroup_tree_mutex);
-       dput(prev);
-       deactivate_super(sb);
+       cgroup_put(prev);
+       cgroup_put_root(ss->root);
        return ret;
 }
 
  */
 static void cgroup_dput(struct cgroup *cgrp)
 {
-       struct super_block *sb = cgrp->root->sb;
-
-       atomic_inc(&sb->s_active);
-       dput(cgrp->dentry);
-       deactivate_super(sb);
+       cgroup_get_root(cgrp->root);
+       cgroup_put(cgrp);
+       cgroup_put_root(cgrp->root);
 }
 
 static u64 cgroup_clone_children_read(struct cgroup_subsys_state *css,
        if (err)
                goto err_free;
 
-       dget(cgrp->dentry);
+       cgroup_get(cgrp);
        css_get(css->parent);
 
        if (ss->broken_hierarchy && !ss->warned_broken_hierarchy &&
         * can be done outside cgroup_mutex, since the sb can't
         * disappear while someone has an open control file on the
         * fs */
-       atomic_inc(&sb->s_active);
+       cgroup_get_root(root);
 
        init_cgroup_housekeeping(cgrp);
 
        root->number_of_cgroups++;
 
        /* hold a ref to the parent's dentry */
-       dget(parent->dentry);
+       cgroup_get(parent);
 
        /*
         * @cgrp is now fully operational.  If something fails after this
 err_free_id:
        idr_remove(&root->cgroup_idr, cgrp->id);
        /* Release the reference count that we took on the superblock */
-       deactivate_super(sb);
+       cgroup_put_root(root);
 err_unlock:
        mutex_unlock(&cgroup_mutex);
 err_unlock_tree:
 static void cgroup_destroy_css_killed(struct cgroup *cgrp)
 {
        struct cgroup *parent = cgrp->parent;
-       struct dentry *d = cgrp->dentry;
 
        lockdep_assert_held(&cgroup_tree_mutex);
        lockdep_assert_held(&cgroup_mutex);
        /* delete this cgroup from parent->children */
        list_del_rcu(&cgrp->sibling);
 
-       dput(d);
+       cgroup_put(cgrp);
 
        set_bit(CGRP_RELEASABLE, &parent->flags);
        check_for_release(parent);
        cset = rcu_dereference(current->cgroups);
        list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
                struct cgroup *c = link->cgrp;
-               const char *name;
+               const char *name = "?";
+
+               if (c != cgroup_dummy_top)
+                       name = cgroup_name(c);
 
-               if (c->dentry)
-                       name = c->dentry->d_name.name;
-               else
-                       name = "?";
                seq_printf(seq, "Root %d group %s\n",
                           c->root->hierarchy_id, name);
        }