struct list_head pidlists;
struct mutex pidlist_mutex;
+ /* dummy css with NULL ->ss, points back to this cgroup */
+ struct cgroup_subsys_state dummy_css;
+
/* For css percpu_ref killing and RCU-protected deletion */
struct rcu_head rcu_head;
struct work_struct destroy_work;
{
struct cgroup *parent_cgrp = css->cgroup->parent;
- return parent_cgrp ? parent_cgrp->subsys[css->ss->subsys_id] : NULL;
+ if (!parent_cgrp)
+ return NULL;
+
+ if (css->ss)
+ return parent_cgrp->subsys[css->ss->subsys_id];
+ else
+ return &parent_cgrp->dummy_css;
}
/**
INIT_LIST_HEAD(&cgrp->release_list);
INIT_LIST_HEAD(&cgrp->pidlists);
mutex_init(&cgrp->pidlist_mutex);
+ cgrp->dummy_css.cgroup = cgrp;
INIT_LIST_HEAD(&cgrp->event_list);
spin_lock_init(&cgrp->event_list_lock);
simple_xattrs_init(&cgrp->xattrs);
if (cft->ss)
return cgrp->subsys[cft->ss->subsys_id];
- return NULL;
+ return &cgrp->dummy_css;
}
/* A buffer size big enough for numbers or short strings */
* unpinned either on open failure or release. This ensures that
* @css stays alive for all file operations.
*/
- if (css && !css_tryget(css))
+ if (css->ss && !css_tryget(css))
return -ENODEV;
if (cft->read_map || cft->read_seq_string) {
err = cft->open(inode, file);
}
- if (css && err)
+ if (css->ss && err)
css_put(css);
return err;
}
if (cft->release)
ret = cft->release(inode, file);
- if (css)
+ if (css->ss)
css_put(css);
return ret;
}