aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-04-16 16:57:25 -0400
committerJens Axboe <axboe@kernel.dk>2012-04-20 04:06:17 -0400
commit3c798398e393e5f9502dbab2b51e6c25e2e8f2ac (patch)
treed6f638e6a25dec4887e64bcc35b98bc394cb974f /block/blk-cgroup.h
parent36558c8a30e121f97b5852ae33e28081af21bdbf (diff)
blkcg: mass rename of blkcg API
During the recent blkcg cleanup, most of blkcg API has changed to such extent that mass renaming wouldn't cause any noticeable pain. Take the chance and cleanup the naming. * Rename blkio_cgroup to blkcg. * Drop blkio / blkiocg prefixes and consistently use blkcg. * Rename blkio_group to blkcg_gq, which is consistent with io_cq but keep the blkg prefix / variable name. * Rename policy method type and field names to signify they're dealing with policy data. * Rename blkio_policy_type to blkcg_policy. This patch doesn't cause any functional 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.h')
-rw-r--r--block/blk-cgroup.h109
1 files changed, 54 insertions, 55 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index b347aa08d166..a443b84d2c16 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -37,7 +37,7 @@ enum blkg_rwstat_type {
37 BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR, 37 BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR,
38}; 38};
39 39
40struct blkio_cgroup { 40struct blkcg {
41 struct cgroup_subsys_state css; 41 struct cgroup_subsys_state css;
42 spinlock_t lock; 42 spinlock_t lock;
43 struct hlist_head blkg_list; 43 struct hlist_head blkg_list;
@@ -45,7 +45,7 @@ struct blkio_cgroup {
45 /* for policies to test whether associated blkcg has changed */ 45 /* for policies to test whether associated blkcg has changed */
46 uint64_t id; 46 uint64_t id;
47 47
48 /* TODO: per-policy storage in blkio_cgroup */ 48 /* TODO: per-policy storage in blkcg */
49 unsigned int cfq_weight; /* belongs to cfq */ 49 unsigned int cfq_weight; /* belongs to cfq */
50}; 50};
51 51
@@ -62,7 +62,7 @@ struct blkg_rwstat {
62/* per-blkg per-policy data */ 62/* per-blkg per-policy data */
63struct blkg_policy_data { 63struct blkg_policy_data {
64 /* the blkg this per-policy data belongs to */ 64 /* the blkg this per-policy data belongs to */
65 struct blkio_group *blkg; 65 struct blkcg_gq *blkg;
66 66
67 /* used during policy activation */ 67 /* used during policy activation */
68 struct list_head alloc_node; 68 struct list_head alloc_node;
@@ -71,12 +71,13 @@ struct blkg_policy_data {
71 char pdata[] __aligned(__alignof__(unsigned long long)); 71 char pdata[] __aligned(__alignof__(unsigned long long));
72}; 72};
73 73
74struct blkio_group { 74/* association between a blk cgroup and a request queue */
75struct blkcg_gq {
75 /* Pointer to the associated request_queue */ 76 /* Pointer to the associated request_queue */
76 struct request_queue *q; 77 struct request_queue *q;
77 struct list_head q_node; 78 struct list_head q_node;
78 struct hlist_node blkcg_node; 79 struct hlist_node blkcg_node;
79 struct blkio_cgroup *blkcg; 80 struct blkcg *blkcg;
80 /* reference count */ 81 /* reference count */
81 int refcnt; 82 int refcnt;
82 83
@@ -85,18 +86,18 @@ struct blkio_group {
85 struct rcu_head rcu_head; 86 struct rcu_head rcu_head;
86}; 87};
87 88
88typedef void (blkio_init_group_fn)(struct blkio_group *blkg); 89typedef void (blkcg_pol_init_pd_fn)(struct blkcg_gq *blkg);
89typedef void (blkio_exit_group_fn)(struct blkio_group *blkg); 90typedef void (blkcg_pol_exit_pd_fn)(struct blkcg_gq *blkg);
90typedef void (blkio_reset_group_stats_fn)(struct blkio_group *blkg); 91typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkcg_gq *blkg);
91 92
92struct blkio_policy_ops { 93struct blkcg_policy_ops {
93 blkio_init_group_fn *blkio_init_group_fn; 94 blkcg_pol_init_pd_fn *pd_init_fn;
94 blkio_exit_group_fn *blkio_exit_group_fn; 95 blkcg_pol_exit_pd_fn *pd_exit_fn;
95 blkio_reset_group_stats_fn *blkio_reset_group_stats_fn; 96 blkcg_pol_reset_pd_stats_fn *pd_reset_stats_fn;
96}; 97};
97 98
98struct blkio_policy_type { 99struct blkcg_policy {
99 struct blkio_policy_ops ops; 100 struct blkcg_policy_ops ops;
100 int plid; 101 int plid;
101 /* policy specific private data size */ 102 /* policy specific private data size */
102 size_t pdata_size; 103 size_t pdata_size;
@@ -104,29 +105,28 @@ struct blkio_policy_type {
104 struct cftype *cftypes; 105 struct cftype *cftypes;
105}; 106};
106 107
107extern struct blkio_cgroup blkio_root_cgroup; 108extern struct blkcg blkcg_root;
108 109
109struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); 110struct blkcg *cgroup_to_blkcg(struct cgroup *cgroup);
110struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio); 111struct blkcg *bio_blkcg(struct bio *bio);
111struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg, 112struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, struct request_queue *q);
112 struct request_queue *q); 113struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
113struct blkio_group *blkg_lookup_create(struct blkio_cgroup *blkcg, 114 struct request_queue *q);
114 struct request_queue *q);
115int blkcg_init_queue(struct request_queue *q); 115int blkcg_init_queue(struct request_queue *q);
116void blkcg_drain_queue(struct request_queue *q); 116void blkcg_drain_queue(struct request_queue *q);
117void blkcg_exit_queue(struct request_queue *q); 117void blkcg_exit_queue(struct request_queue *q);
118 118
119/* Blkio controller policy registration */ 119/* Blkio controller policy registration */
120int blkio_policy_register(struct blkio_policy_type *); 120int blkcg_policy_register(struct blkcg_policy *pol);
121void blkio_policy_unregister(struct blkio_policy_type *); 121void blkcg_policy_unregister(struct blkcg_policy *pol);
122int blkcg_activate_policy(struct request_queue *q, 122int blkcg_activate_policy(struct request_queue *q,
123 const struct blkio_policy_type *pol); 123 const struct blkcg_policy *pol);
124void blkcg_deactivate_policy(struct request_queue *q, 124void blkcg_deactivate_policy(struct request_queue *q,
125 const struct blkio_policy_type *pol); 125 const struct blkcg_policy *pol);
126 126
127void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, 127void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
128 u64 (*prfill)(struct seq_file *, void *, int), 128 u64 (*prfill)(struct seq_file *, void *, int),
129 const struct blkio_policy_type *pol, int data, 129 const struct blkcg_policy *pol, int data,
130 bool show_total); 130 bool show_total);
131u64 __blkg_prfill_u64(struct seq_file *sf, void *pdata, u64 v); 131u64 __blkg_prfill_u64(struct seq_file *sf, void *pdata, u64 v);
132u64 __blkg_prfill_rwstat(struct seq_file *sf, void *pdata, 132u64 __blkg_prfill_rwstat(struct seq_file *sf, void *pdata,
@@ -136,13 +136,12 @@ u64 blkg_prfill_rwstat(struct seq_file *sf, void *pdata, int off);
136 136
137struct blkg_conf_ctx { 137struct blkg_conf_ctx {
138 struct gendisk *disk; 138 struct gendisk *disk;
139 struct blkio_group *blkg; 139 struct blkcg_gq *blkg;
140 u64 v; 140 u64 v;
141}; 141};
142 142
143int blkg_conf_prep(struct blkio_cgroup *blkcg, 143int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
144 const struct blkio_policy_type *pol, const char *input, 144 const char *input, struct blkg_conf_ctx *ctx);
145 struct blkg_conf_ctx *ctx);
146void blkg_conf_finish(struct blkg_conf_ctx *ctx); 145void blkg_conf_finish(struct blkg_conf_ctx *ctx);
147 146
148 147
@@ -153,8 +152,8 @@ void blkg_conf_finish(struct blkg_conf_ctx *ctx);
153 * 152 *
154 * Return pointer to private data associated with the @blkg-@pol pair. 153 * Return pointer to private data associated with the @blkg-@pol pair.
155 */ 154 */
156static inline void *blkg_to_pdata(struct blkio_group *blkg, 155static inline void *blkg_to_pdata(struct blkcg_gq *blkg,
157 struct blkio_policy_type *pol) 156 struct blkcg_policy *pol)
158{ 157{
159 return blkg ? blkg->pd[pol->plid]->pdata : NULL; 158 return blkg ? blkg->pd[pol->plid]->pdata : NULL;
160} 159}
@@ -165,7 +164,7 @@ static inline void *blkg_to_pdata(struct blkio_group *blkg,
165 * 164 *
166 * @pdata is policy private data. Determine the blkg it's associated with. 165 * @pdata is policy private data. Determine the blkg it's associated with.
167 */ 166 */
168static inline struct blkio_group *pdata_to_blkg(void *pdata) 167static inline struct blkcg_gq *pdata_to_blkg(void *pdata)
169{ 168{
170 if (pdata) { 169 if (pdata) {
171 struct blkg_policy_data *pd = 170 struct blkg_policy_data *pd =
@@ -183,7 +182,7 @@ static inline struct blkio_group *pdata_to_blkg(void *pdata)
183 * 182 *
184 * Format the path of the cgroup of @blkg into @buf. 183 * Format the path of the cgroup of @blkg into @buf.
185 */ 184 */
186static inline int blkg_path(struct blkio_group *blkg, char *buf, int buflen) 185static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
187{ 186{
188 int ret; 187 int ret;
189 188
@@ -201,14 +200,14 @@ static inline int blkg_path(struct blkio_group *blkg, char *buf, int buflen)
201 * 200 *
202 * The caller should be holding queue_lock and an existing reference. 201 * The caller should be holding queue_lock and an existing reference.
203 */ 202 */
204static inline void blkg_get(struct blkio_group *blkg) 203static inline void blkg_get(struct blkcg_gq *blkg)
205{ 204{
206 lockdep_assert_held(blkg->q->queue_lock); 205 lockdep_assert_held(blkg->q->queue_lock);
207 WARN_ON_ONCE(!blkg->refcnt); 206 WARN_ON_ONCE(!blkg->refcnt);
208 blkg->refcnt++; 207 blkg->refcnt++;
209} 208}
210 209
211void __blkg_release(struct blkio_group *blkg); 210void __blkg_release(struct blkcg_gq *blkg);
212 211
213/** 212/**
214 * blkg_put - put a blkg reference 213 * blkg_put - put a blkg reference
@@ -216,7 +215,7 @@ void __blkg_release(struct blkio_group *blkg);
216 * 215 *
217 * The caller should be holding queue_lock. 216 * The caller should be holding queue_lock.
218 */ 217 */
219static inline void blkg_put(struct blkio_group *blkg) 218static inline void blkg_put(struct blkcg_gq *blkg)
220{ 219{
221 lockdep_assert_held(blkg->q->queue_lock); 220 lockdep_assert_held(blkg->q->queue_lock);
222 WARN_ON_ONCE(blkg->refcnt <= 0); 221 WARN_ON_ONCE(blkg->refcnt <= 0);
@@ -343,32 +342,32 @@ static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
343 342
344struct cgroup; 343struct cgroup;
345 344
346struct blkio_group { 345struct blkcg_gq {
347}; 346};
348 347
349struct blkio_policy_type { 348struct blkcg_policy {
350}; 349};
351 350
352static inline struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } 351static inline struct blkcg *cgroup_to_blkcg(struct cgroup *cgroup) { return NULL; }
353static inline struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio) { return NULL; } 352static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; }
354static inline struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg, void *key) { return NULL; } 353static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; }
355static inline int blkcg_init_queue(struct request_queue *q) { return 0; } 354static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
356static inline void blkcg_drain_queue(struct request_queue *q) { } 355static inline void blkcg_drain_queue(struct request_queue *q) { }
357static inline void blkcg_exit_queue(struct request_queue *q) { } 356static inline void blkcg_exit_queue(struct request_queue *q) { }
358static inline int blkio_policy_register(struct blkio_policy_type *blkiop) { return 0; } 357static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; }
359static inline void blkio_policy_unregister(struct blkio_policy_type *blkiop) { } 358static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { }
360static inline int blkcg_activate_policy(struct request_queue *q, 359static inline int blkcg_activate_policy(struct request_queue *q,
361 const struct blkio_policy_type *pol) { return 0; } 360 const struct blkcg_policy *pol) { return 0; }
362static inline void blkcg_deactivate_policy(struct request_queue *q, 361static inline void blkcg_deactivate_policy(struct request_queue *q,
363 const struct blkio_policy_type *pol) { } 362 const struct blkcg_policy *pol) { }
364 363
365static inline void *blkg_to_pdata(struct blkio_group *blkg, 364static inline void *blkg_to_pdata(struct blkcg_gq *blkg,
366 struct blkio_policy_type *pol) { return NULL; } 365 struct blkcg_policy *pol) { return NULL; }
367static inline struct blkio_group *pdata_to_blkg(void *pdata, 366static inline struct blkcg_gq *pdata_to_blkg(void *pdata,
368 struct blkio_policy_type *pol) { return NULL; } 367 struct blkcg_policy *pol) { return NULL; }
369static inline char *blkg_path(struct blkio_group *blkg) { return NULL; } 368static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; }
370static inline void blkg_get(struct blkio_group *blkg) { } 369static inline void blkg_get(struct blkcg_gq *blkg) { }
371static inline void blkg_put(struct blkio_group *blkg) { } 370static inline void blkg_put(struct blkcg_gq *blkg) { }
372 371
373#endif /* CONFIG_BLK_CGROUP */ 372#endif /* CONFIG_BLK_CGROUP */
374#endif /* _BLK_CGROUP_H */ 373#endif /* _BLK_CGROUP_H */