/* Subsystem is in this hierarchy. So we want
* the subsystem state from the new
* cgroup */
- template[i] = cgrp->subsys[i];
+ template[i] = cgroup_css(cgrp, i);
} else {
/* Subsystem is not in this hierarchy, so we
* don't want to change the subsystem state */
* Release the subsystem state objects.
*/
for_each_root_subsys(cgrp->root, ss) {
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
ss->css_free(css);
}
if (bit & added_mask) {
/* We're binding this subsystem to this hierarchy */
- BUG_ON(cgrp->subsys[i]);
- BUG_ON(!cgroup_dummy_top->subsys[i]);
- BUG_ON(cgroup_dummy_top->subsys[i]->cgroup != cgroup_dummy_top);
+ BUG_ON(cgroup_css(cgrp, i));
+ BUG_ON(!cgroup_css(cgroup_dummy_top, i));
+ BUG_ON(cgroup_css(cgroup_dummy_top, i)->cgroup != cgroup_dummy_top);
cgrp->subsys[i] = cgroup_dummy_top->subsys[i];
- cgrp->subsys[i]->cgroup = cgrp;
+ cgroup_css(cgrp, i)->cgroup = cgrp;
list_move(&ss->sibling, &root->subsys_list);
ss->root = root;
if (ss->bind)
- ss->bind(cgrp->subsys[i]);
+ ss->bind(cgroup_css(cgrp, i));
/* refcount was already taken, and we're keeping it */
root->subsys_mask |= bit;
} else if (bit & removed_mask) {
/* We're removing this subsystem */
- BUG_ON(cgrp->subsys[i] != cgroup_dummy_top->subsys[i]);
- BUG_ON(cgrp->subsys[i]->cgroup != cgrp);
+ BUG_ON(cgroup_css(cgrp, i) != cgroup_css(cgroup_dummy_top, i));
+ BUG_ON(cgroup_css(cgrp, i)->cgroup != cgrp);
if (ss->bind)
- ss->bind(cgroup_dummy_top->subsys[i]);
- cgroup_dummy_top->subsys[i]->cgroup = cgroup_dummy_top;
+ ss->bind(cgroup_css(cgroup_dummy_top, i));
+ cgroup_css(cgroup_dummy_top, i)->cgroup = cgroup_dummy_top;
cgrp->subsys[i] = NULL;
cgroup_subsys[i]->root = &cgroup_dummy_root;
list_move(&ss->sibling, &cgroup_dummy_root.subsys_list);
* step 1: check that we can legitimately attach to the cgroup.
*/
for_each_root_subsys(root, ss) {
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
if (ss->can_attach) {
retval = ss->can_attach(css, &tset);
* step 4: do subsystem attach callbacks.
*/
for_each_root_subsys(root, ss) {
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
if (ss->attach)
ss->attach(css, &tset);
out_cancel_attach:
if (retval) {
for_each_root_subsys(root, ss) {
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
if (ss == failed_ss)
break;
struct cgroup *cgrp = __d_cgrp(cfe->dentry->d_parent);
if (cft->ss)
- return cgrp->subsys[cft->ss->subsys_id];
+ return cgroup_css(cgrp, cft->ss->subsys_id);
return &cgrp->dummy_css;
}
/* This cgroup is ready now */
for_each_root_subsys(cgrp->root, ss) {
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
struct css_id *id = rcu_dereference_protected(css->id, true);
/*
css->id = NULL;
if (cgrp == cgroup_dummy_top)
css->flags |= CSS_ROOT;
- BUG_ON(cgrp->subsys[ss->subsys_id]);
+ BUG_ON(cgroup_css(cgrp, ss->subsys_id));
cgrp->subsys[ss->subsys_id] = css;
/*
/* invoke ->css_online() on a new CSS and mark it online if successful */
static int online_css(struct cgroup_subsys *ss, struct cgroup *cgrp)
{
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
int ret = 0;
lockdep_assert_held(&cgroup_mutex);
/* if the CSS is online, invoke ->css_offline() on it and mark it offline */
static void offline_css(struct cgroup_subsys *ss, struct cgroup *cgrp)
{
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
lockdep_assert_held(&cgroup_mutex);
for_each_root_subsys(root, ss) {
struct cgroup_subsys_state *css;
- css = ss->css_alloc(parent->subsys[ss->subsys_id]);
+ css = ss->css_alloc(cgroup_css(parent, ss->subsys_id));
if (IS_ERR(css)) {
err = PTR_ERR(css);
goto err_free_all;
err_free_all:
for_each_root_subsys(root, ss) {
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
if (css) {
percpu_ref_cancel_init(&css->refcnt);
*/
atomic_set(&cgrp->css_kill_cnt, 1);
for_each_root_subsys(cgrp->root, ss) {
- struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ struct cgroup_subsys_state *css = cgroup_css(cgrp, ss->subsys_id);
/*
* Killing would put the base ref, but we need to keep it
* destruction happens only after all css's are released.
*/
for_each_root_subsys(cgrp->root, ss)
- css_put(cgrp->subsys[ss->subsys_id]);
+ css_put(cgroup_css(cgrp, ss->subsys_id));
/* delete this cgroup from parent->children */
list_del_rcu(&cgrp->sibling);
/* Create the top cgroup state for this subsystem */
list_add(&ss->sibling, &cgroup_dummy_root.subsys_list);
ss->root = &cgroup_dummy_root;
- css = ss->css_alloc(cgroup_dummy_top->subsys[ss->subsys_id]);
+ css = ss->css_alloc(cgroup_css(cgroup_dummy_top, ss->subsys_id));
/* We don't handle early failures gracefully */
BUG_ON(IS_ERR(css));
init_cgroup_css(css, ss, cgroup_dummy_top);
* struct, so this can happen first (i.e. before the dummy root
* attachment).
*/
- css = ss->css_alloc(cgroup_dummy_top->subsys[ss->subsys_id]);
+ css = ss->css_alloc(cgroup_css(cgroup_dummy_top, ss->subsys_id));
if (IS_ERR(css)) {
/* failure case - need to deassign the cgroup_subsys[] slot. */
cgroup_subsys[ss->subsys_id] = NULL;
* the cgrp->subsys pointer to find their state. note that this
* also takes care of freeing the css_id.
*/
- ss->css_free(cgroup_dummy_top->subsys[ss->subsys_id]);
+ ss->css_free(cgroup_css(cgroup_dummy_top, ss->subsys_id));
cgroup_dummy_top->subsys[ss->subsys_id] = NULL;
mutex_unlock(&cgroup_mutex);
struct css_id *child_id, *parent_id;
subsys_id = ss->subsys_id;
- parent_css = parent->subsys[subsys_id];
- child_css = child->subsys[subsys_id];
+ parent_css = cgroup_css(parent, subsys_id);
+ child_css = cgroup_css(child, subsys_id);
parent_id = rcu_dereference_protected(parent_css->id, true);
depth = parent_id->depth + 1;
/* get cgroup */
cgrp = __d_cgrp(f->f_dentry);
- css = cgrp->subsys[id];
+ css = cgroup_css(cgrp, id);
return css ? css : ERR_PTR(-ENOENT);
}