aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:06 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:22 -0500
commitcd1604fab4f95f7cfc227d3955fd7ae14da61f38 (patch)
tree021881faedc1c2468730f9f54d364083e70dce76 /block/blk-cgroup.h
parentf51b802c17e2a21926b29911493f5e7ddf6eee87 (diff)
blkcg: factor out blkio_group creation
Currently both blk-throttle and cfq-iosched implement their own blkio_group creation code in throtl_get_tg() and cfq_get_cfqg(). This patch factors out the common code into blkg_lookup_create(), which returns ERR_PTR value so that transitional failures due to queue bypass can be distinguished from other failures. * New plkio_policy_ops methods blkio_alloc_group_fn() and blkio_link_group_fn added. Both are transitional and will be removed once the blkg management code is fully moved into blk-cgroup.c. * blkio_alloc_group_fn() allocates policy-specific blkg which is usually a larger data structure with blkg as the first entry and intiailizes it. Note that initialization of blkg proper, including percpu stats, is responsibility of blk-cgroup proper. Note that default config (weight, bps...) initialization is done from this method; otherwise, we end up violating locking order between blkcg and q locks via blkcg_get_CONF() functions. * blkio_link_group_fn() is called under queue_lock and responsible for linking the blkg to the queue. blkcg side is handled by blk-cgroup proper. * The common blkg creation function is named blkg_lookup_create() and blkiocg_lookup_group() is renamed to blkg_lookup() for consistency. Also, throtl / cfq related functions are similarly [re]named for consistency. This simplifies blkcg policy implementations and enables further cleanup. -v2: Vivek noticed that blkg_lookup_create() incorrectly tested blk_queue_dead() instead of blk_queue_bypass() leading a user of the function ending up creating a new blkg on bypassing queue. This is a bug introduced while relocating bypass patches before this one. Fixed. -v3: ERR_PTR patch folded into this one. @for_root added to blkg_lookup_create() to allow creating root group on a bypassed queue during elevator switch. 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.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 562fa55d97b1..2600ae7e6f60 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -204,6 +204,10 @@ extern unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg,
204extern unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg, 204extern unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg,
205 dev_t dev); 205 dev_t dev);
206 206
207typedef struct blkio_group *(blkio_alloc_group_fn)(struct request_queue *q,
208 struct blkio_cgroup *blkcg);
209typedef void (blkio_link_group_fn)(struct request_queue *q,
210 struct blkio_group *blkg);
207typedef void (blkio_unlink_group_fn)(struct request_queue *q, 211typedef void (blkio_unlink_group_fn)(struct request_queue *q,
208 struct blkio_group *blkg); 212 struct blkio_group *blkg);
209typedef bool (blkio_clear_queue_fn)(struct request_queue *q); 213typedef bool (blkio_clear_queue_fn)(struct request_queue *q);
@@ -219,6 +223,8 @@ typedef void (blkio_update_group_write_iops_fn)(struct request_queue *q,
219 struct blkio_group *blkg, unsigned int write_iops); 223 struct blkio_group *blkg, unsigned int write_iops);
220 224
221struct blkio_policy_ops { 225struct blkio_policy_ops {
226 blkio_alloc_group_fn *blkio_alloc_group_fn;
227 blkio_link_group_fn *blkio_link_group_fn;
222 blkio_unlink_group_fn *blkio_unlink_group_fn; 228 blkio_unlink_group_fn *blkio_unlink_group_fn;
223 blkio_clear_queue_fn *blkio_clear_queue_fn; 229 blkio_clear_queue_fn *blkio_clear_queue_fn;
224 blkio_update_group_weight_fn *blkio_update_group_weight_fn; 230 blkio_update_group_weight_fn *blkio_update_group_weight_fn;
@@ -307,14 +313,14 @@ static inline void blkiocg_set_start_empty_time(struct blkio_group *blkg) {}
307extern struct blkio_cgroup blkio_root_cgroup; 313extern struct blkio_cgroup blkio_root_cgroup;
308extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); 314extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
309extern struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk); 315extern struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk);
310extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
311 struct blkio_group *blkg, struct request_queue *q, dev_t dev,
312 enum blkio_policy_id plid);
313extern int blkio_alloc_blkg_stats(struct blkio_group *blkg);
314extern int blkiocg_del_blkio_group(struct blkio_group *blkg); 316extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
315extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, 317extern struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
316 struct request_queue *q, 318 struct request_queue *q,
317 enum blkio_policy_id plid); 319 enum blkio_policy_id plid);
320struct blkio_group *blkg_lookup_create(struct blkio_cgroup *blkcg,
321 struct request_queue *q,
322 enum blkio_policy_id plid,
323 bool for_root);
318void blkiocg_update_timeslice_used(struct blkio_group *blkg, 324void blkiocg_update_timeslice_used(struct blkio_group *blkg,
319 unsigned long time, 325 unsigned long time,
320 unsigned long unaccounted_time); 326 unsigned long unaccounted_time);
@@ -335,17 +341,11 @@ cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
335static inline struct blkio_cgroup * 341static inline struct blkio_cgroup *
336task_blkio_cgroup(struct task_struct *tsk) { return NULL; } 342task_blkio_cgroup(struct task_struct *tsk) { return NULL; }
337 343
338static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
339 struct blkio_group *blkg, void *key, dev_t dev,
340 enum blkio_policy_id plid) {}
341
342static inline int blkio_alloc_blkg_stats(struct blkio_group *blkg) { return 0; }
343
344static inline int 344static inline int
345blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } 345blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
346 346
347static inline struct blkio_group * 347static inline struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
348blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; } 348 void *key) { return NULL; }
349static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg, 349static inline void blkiocg_update_timeslice_used(struct blkio_group *blkg,
350 unsigned long time, 350 unsigned long time,
351 unsigned long unaccounted_time) 351 unsigned long unaccounted_time)