aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:28 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:24 -0500
commit4f85cb96d9d2fbbb7160db855a6beee1baced5e5 (patch)
tree5472bba04490da05fa6ca8f780431b37bd7375cb /block/blk-cgroup.c
parent852c788f8365062c8a383c5a93f7f7289977cb50 (diff)
block: make block cgroup policies follow bio task association
Implement bio_blkio_cgroup() which returns the blkcg associated with the bio if exists or %current's blkcg, and use it in blk-throttle and cfq-iosched propio. This makes both cgroup policies honor task association for the bio instead of always assuming %current. As nobody is using bio_set_task() yet, this doesn't introduce any behavior change. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 27d39a810cb6..ee962f327ba5 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -71,12 +71,19 @@ struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup)
71} 71}
72EXPORT_SYMBOL_GPL(cgroup_to_blkio_cgroup); 72EXPORT_SYMBOL_GPL(cgroup_to_blkio_cgroup);
73 73
74struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk) 74static struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk)
75{ 75{
76 return container_of(task_subsys_state(tsk, blkio_subsys_id), 76 return container_of(task_subsys_state(tsk, blkio_subsys_id),
77 struct blkio_cgroup, css); 77 struct blkio_cgroup, css);
78} 78}
79EXPORT_SYMBOL_GPL(task_blkio_cgroup); 79
80struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio)
81{
82 if (bio && bio->bi_css)
83 return container_of(bio->bi_css, struct blkio_cgroup, css);
84 return task_blkio_cgroup(current);
85}
86EXPORT_SYMBOL_GPL(bio_blkio_cgroup);
80 87
81static inline void blkio_update_group_weight(struct blkio_group *blkg, 88static inline void blkio_update_group_weight(struct blkio_group *blkg,
82 int plid, unsigned int weight) 89 int plid, unsigned int weight)