diff options
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r-- | block/blk-cgroup.h | 35 |
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 | ||
193 | typedef void (blkio_init_group_fn)(struct blkio_group *blkg); | 197 | typedef 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 | */ | ||
285 | static 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 | |||
292 | void __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 | */ | ||
300 | static 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 | ||
277 | struct blkio_group { | 310 | struct blkio_group { |
@@ -292,6 +325,8 @@ static inline void *blkg_to_pdata(struct blkio_group *blkg, | |||
292 | static inline struct blkio_group *pdata_to_blkg(void *pdata, | 325 | static 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; } |
294 | static inline char *blkg_path(struct blkio_group *blkg) { return NULL; } | 327 | static inline char *blkg_path(struct blkio_group *blkg) { return NULL; } |
328 | static inline void blkg_get(struct blkio_group *blkg) { } | ||
329 | static inline void blkg_put(struct blkio_group *blkg) { } | ||
295 | 330 | ||
296 | #endif | 331 | #endif |
297 | 332 | ||