diff options
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r-- | block/blk-cgroup.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index 4e595ee8c915..8056c03a3382 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
@@ -266,7 +266,7 @@ static inline void blkg_get(struct blkcg_gq *blkg) | |||
266 | blkg->refcnt++; | 266 | blkg->refcnt++; |
267 | } | 267 | } |
268 | 268 | ||
269 | void __blkg_release(struct blkcg_gq *blkg); | 269 | void __blkg_release_rcu(struct rcu_head *rcu); |
270 | 270 | ||
271 | /** | 271 | /** |
272 | * blkg_put - put a blkg reference | 272 | * blkg_put - put a blkg reference |
@@ -279,9 +279,43 @@ static inline void blkg_put(struct blkcg_gq *blkg) | |||
279 | lockdep_assert_held(blkg->q->queue_lock); | 279 | lockdep_assert_held(blkg->q->queue_lock); |
280 | WARN_ON_ONCE(blkg->refcnt <= 0); | 280 | WARN_ON_ONCE(blkg->refcnt <= 0); |
281 | if (!--blkg->refcnt) | 281 | if (!--blkg->refcnt) |
282 | __blkg_release(blkg); | 282 | call_rcu(&blkg->rcu_head, __blkg_release_rcu); |
283 | } | 283 | } |
284 | 284 | ||
285 | struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg, struct request_queue *q, | ||
286 | bool update_hint); | ||
287 | |||
288 | /** | ||
289 | * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants | ||
290 | * @d_blkg: loop cursor pointing to the current descendant | ||
291 | * @pos_cgrp: used for iteration | ||
292 | * @p_blkg: target blkg to walk descendants of | ||
293 | * | ||
294 | * Walk @c_blkg through the descendants of @p_blkg. Must be used with RCU | ||
295 | * read locked. If called under either blkcg or queue lock, the iteration | ||
296 | * is guaranteed to include all and only online blkgs. The caller may | ||
297 | * update @pos_cgrp by calling cgroup_rightmost_descendant() to skip | ||
298 | * subtree. | ||
299 | */ | ||
300 | #define blkg_for_each_descendant_pre(d_blkg, pos_cgrp, p_blkg) \ | ||
301 | cgroup_for_each_descendant_pre((pos_cgrp), (p_blkg)->blkcg->css.cgroup) \ | ||
302 | if (((d_blkg) = __blkg_lookup(cgroup_to_blkcg(pos_cgrp), \ | ||
303 | (p_blkg)->q, false))) | ||
304 | |||
305 | /** | ||
306 | * blkg_for_each_descendant_post - post-order walk of a blkg's descendants | ||
307 | * @d_blkg: loop cursor pointing to the current descendant | ||
308 | * @pos_cgrp: used for iteration | ||
309 | * @p_blkg: target blkg to walk descendants of | ||
310 | * | ||
311 | * Similar to blkg_for_each_descendant_pre() but performs post-order | ||
312 | * traversal instead. Synchronization rules are the same. | ||
313 | */ | ||
314 | #define blkg_for_each_descendant_post(d_blkg, pos_cgrp, p_blkg) \ | ||
315 | cgroup_for_each_descendant_post((pos_cgrp), (p_blkg)->blkcg->css.cgroup) \ | ||
316 | if (((d_blkg) = __blkg_lookup(cgroup_to_blkcg(pos_cgrp), \ | ||
317 | (p_blkg)->q, false))) | ||
318 | |||
285 | /** | 319 | /** |
286 | * blk_get_rl - get request_list to use | 320 | * blk_get_rl - get request_list to use |
287 | * @q: request_queue of interest | 321 | * @q: request_queue of interest |