cgroup: add css_parent()
[linux-2.6-block.git] / include / linux / cgroup.h
index 821678aae4db607aa0bcc539107bbf6c441597a7..18112a3bb12bc2a80a4c48d979774ad28ef23166 100644 (file)
@@ -646,6 +646,21 @@ struct cgroup_subsys {
 #undef IS_SUBSYS_ENABLED
 #undef SUBSYS
 
+/**
+ * css_parent - find the parent css
+ * @css: the target cgroup_subsys_state
+ *
+ * Return the parent css of @css.  This function is guaranteed to return
+ * non-NULL parent as long as @css isn't the root.
+ */
+static inline
+struct cgroup_subsys_state *css_parent(struct cgroup_subsys_state *css)
+{
+       struct cgroup *parent_cgrp = css->cgroup->parent;
+
+       return parent_cgrp ? parent_cgrp->subsys[css->ss->subsys_id] : NULL;
+}
+
 /**
  * cgroup_css - obtain a cgroup's css for the specified subsystem
  * @cgrp: the cgroup of interest