summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/blk-cgroup.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 628e50f6f8a8..8e5863e900bf 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -179,21 +179,25 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
void blkg_conf_finish(struct blkg_conf_ctx *ctx);
+static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css)
+{
+ return css ? container_of(css, struct blkcg, css) : NULL;
+}
+
static inline struct blkcg *cgroup_to_blkcg(struct cgroup *cgroup)
{
- return container_of(cgroup_css(cgroup, blkio_subsys_id),
- struct blkcg, css);
+ return css_to_blkcg(cgroup_css(cgroup, blkio_subsys_id));
}
static inline struct blkcg *task_blkcg(struct task_struct *tsk)
{
- return container_of(task_css(tsk, blkio_subsys_id), struct blkcg, css);
+ return css_to_blkcg(task_css(tsk, blkio_subsys_id));
}
static inline struct blkcg *bio_blkcg(struct bio *bio)
{
if (bio && bio->bi_css)
- return container_of(bio->bi_css, struct blkcg, css);
+ return css_to_blkcg(bio->bi_css);
return task_blkcg(current);
}