aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:15 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:23 -0500
commit1adaf3dde37a8b9b59ea59c5f58fed7761178383 (patch)
treee4a46485b1bf0370aa41a5b9a8f138fba34c9d23 /block/blk-cgroup.h
parent0381411e4b1a52cee134eb73750e5e3cc1155d09 (diff)
blkcg: move refcnt to blkcg core
Currently, blkcg policy implementations manage blkg refcnt duplicating mostly identical code in both policies. This patch moves refcnt to blkg and let blkcg core handle refcnt and freeing of blkgs. * cfq blkgs now also get freed via RCU. * cfq blkgs lose RB_EMPTY_ROOT() sanity check on blkg free. If necessary, we can add blkio_exit_group_fn() to resurrect this. 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.h')
-rw-r--r--block/blk-cgroup.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 9537819c29c6..7da106843f01 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -177,6 +177,8 @@ struct blkio_group {
177 char path[128]; 177 char path[128];
178 /* policy which owns this blk group */ 178 /* policy which owns this blk group */
179 enum blkio_policy_id plid; 179 enum blkio_policy_id plid;
180 /* reference count */
181 int refcnt;
180 182
181 /* Configuration */ 183 /* Configuration */
182 struct blkio_group_conf conf; 184 struct blkio_group_conf conf;
@@ -188,6 +190,8 @@ struct blkio_group {
188 struct blkio_group_stats_cpu __percpu *stats_cpu; 190 struct blkio_group_stats_cpu __percpu *stats_cpu;
189 191
190 struct blkg_policy_data *pd; 192 struct blkg_policy_data *pd;
193
194 struct rcu_head rcu_head;
191}; 195};
192 196
193typedef void (blkio_init_group_fn)(struct blkio_group *blkg); 197typedef void (blkio_init_group_fn)(struct blkio_group *blkg);
@@ -272,6 +276,35 @@ static inline char *blkg_path(struct blkio_group *blkg)
272 return blkg->path; 276 return blkg->path;
273} 277}
274 278
279/**
280 * blkg_get - get a blkg reference
281 * @blkg: blkg to get
282 *
283 * The caller should be holding queue_lock and an existing reference.
284 */
285static inline void blkg_get(struct blkio_group *blkg)
286{
287 lockdep_assert_held(blkg->q->queue_lock);
288 WARN_ON_ONCE(!blkg->refcnt);
289 blkg->refcnt++;
290}
291
292void __blkg_release(struct blkio_group *blkg);
293
294/**
295 * blkg_put - put a blkg reference
296 * @blkg: blkg to put
297 *
298 * The caller should be holding queue_lock.
299 */
300static inline void blkg_put(struct blkio_group *blkg)
301{
302 lockdep_assert_held(blkg->q->queue_lock);
303 WARN_ON_ONCE(blkg->refcnt <= 0);
304 if (!--blkg->refcnt)
305 __blkg_release(blkg);
306}
307
275#else 308#else
276 309
277struct blkio_group { 310struct blkio_group {
@@ -292,6 +325,8 @@ static inline void *blkg_to_pdata(struct blkio_group *blkg,
292static inline struct blkio_group *pdata_to_blkg(void *pdata, 325static inline struct blkio_group *pdata_to_blkg(void *pdata,
293 struct blkio_policy_type *pol) { return NULL; } 326 struct blkio_policy_type *pol) { return NULL; }
294static inline char *blkg_path(struct blkio_group *blkg) { return NULL; } 327static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
328static inline void blkg_get(struct blkio_group *blkg) { }
329static inline void blkg_put(struct blkio_group *blkg) { }
295 330
296#endif 331#endif
297 332