aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blk-cgroup.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/blk-cgroup.h')
-rw-r--r--include/linux/blk-cgroup.h45
1 files changed, 44 insertions, 1 deletions
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 34aec30e06c7..6d766a19f2bb 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -56,6 +56,7 @@ struct blkcg {
56 struct list_head all_blkcgs_node; 56 struct list_head all_blkcgs_node;
57#ifdef CONFIG_CGROUP_WRITEBACK 57#ifdef CONFIG_CGROUP_WRITEBACK
58 struct list_head cgwb_list; 58 struct list_head cgwb_list;
59 refcount_t cgwb_refcnt;
59#endif 60#endif
60}; 61};
61 62
@@ -89,7 +90,6 @@ struct blkg_policy_data {
89 /* the blkg and policy id this per-policy data belongs to */ 90 /* the blkg and policy id this per-policy data belongs to */
90 struct blkcg_gq *blkg; 91 struct blkcg_gq *blkg;
91 int plid; 92 int plid;
92 bool offline;
93}; 93};
94 94
95/* 95/*
@@ -387,6 +387,49 @@ static inline struct blkcg *cpd_to_blkcg(struct blkcg_policy_data *cpd)
387 return cpd ? cpd->blkcg : NULL; 387 return cpd ? cpd->blkcg : NULL;
388} 388}
389 389
390extern void blkcg_destroy_blkgs(struct blkcg *blkcg);
391
392#ifdef CONFIG_CGROUP_WRITEBACK
393
394/**
395 * blkcg_cgwb_get - get a reference for blkcg->cgwb_list
396 * @blkcg: blkcg of interest
397 *
398 * This is used to track the number of active wb's related to a blkcg.
399 */
400static inline void blkcg_cgwb_get(struct blkcg *blkcg)
401{
402 refcount_inc(&blkcg->cgwb_refcnt);
403}
404
405/**
406 * blkcg_cgwb_put - put a reference for @blkcg->cgwb_list
407 * @blkcg: blkcg of interest
408 *
409 * This is used to track the number of active wb's related to a blkcg.
410 * When this count goes to zero, all active wb has finished so the
411 * blkcg can continue destruction by calling blkcg_destroy_blkgs().
412 * This work may occur in cgwb_release_workfn() on the cgwb_release
413 * workqueue.
414 */
415static inline void blkcg_cgwb_put(struct blkcg *blkcg)
416{
417 if (refcount_dec_and_test(&blkcg->cgwb_refcnt))
418 blkcg_destroy_blkgs(blkcg);
419}
420
421#else
422
423static inline void blkcg_cgwb_get(struct blkcg *blkcg) { }
424
425static inline void blkcg_cgwb_put(struct blkcg *blkcg)
426{
427 /* wb isn't being accounted, so trigger destruction right away */
428 blkcg_destroy_blkgs(blkcg);
429}
430
431#endif
432
390/** 433/**
391 * blkg_path - format cgroup path of blkg 434 * blkg_path - format cgroup path of blkg
392 * @blkg: blkg of interest 435 * @blkg: blkg of interest