diff options
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r-- | block/blk-cgroup.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 4d4a277b2905..3ad497f4eed6 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -15,7 +15,9 @@ | |||
15 | #include <linux/kdev_t.h> | 15 | #include <linux/kdev_t.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include "blk-cgroup.h" | 17 | #include "blk-cgroup.h" |
18 | #include "cfq-iosched.h" | 18 | |
19 | static DEFINE_SPINLOCK(blkio_list_lock); | ||
20 | static LIST_HEAD(blkio_list); | ||
19 | 21 | ||
20 | struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; | 22 | struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; |
21 | EXPORT_SYMBOL_GPL(blkio_root_cgroup); | 23 | EXPORT_SYMBOL_GPL(blkio_root_cgroup); |
@@ -138,6 +140,7 @@ blkiocg_weight_write(struct cgroup *cgroup, struct cftype *cftype, u64 val) | |||
138 | struct blkio_cgroup *blkcg; | 140 | struct blkio_cgroup *blkcg; |
139 | struct blkio_group *blkg; | 141 | struct blkio_group *blkg; |
140 | struct hlist_node *n; | 142 | struct hlist_node *n; |
143 | struct blkio_policy_type *blkiop; | ||
141 | 144 | ||
142 | if (val < BLKIO_WEIGHT_MIN || val > BLKIO_WEIGHT_MAX) | 145 | if (val < BLKIO_WEIGHT_MIN || val > BLKIO_WEIGHT_MAX) |
143 | return -EINVAL; | 146 | return -EINVAL; |
@@ -145,8 +148,13 @@ blkiocg_weight_write(struct cgroup *cgroup, struct cftype *cftype, u64 val) | |||
145 | blkcg = cgroup_to_blkio_cgroup(cgroup); | 148 | blkcg = cgroup_to_blkio_cgroup(cgroup); |
146 | spin_lock_irq(&blkcg->lock); | 149 | spin_lock_irq(&blkcg->lock); |
147 | blkcg->weight = (unsigned int)val; | 150 | blkcg->weight = (unsigned int)val; |
148 | hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) | 151 | hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) { |
149 | cfq_update_blkio_group_weight(blkg, blkcg->weight); | 152 | spin_lock(&blkio_list_lock); |
153 | list_for_each_entry(blkiop, &blkio_list, list) | ||
154 | blkiop->ops.blkio_update_group_weight_fn(blkg, | ||
155 | blkcg->weight); | ||
156 | spin_unlock(&blkio_list_lock); | ||
157 | } | ||
150 | spin_unlock_irq(&blkcg->lock); | 158 | spin_unlock_irq(&blkcg->lock); |
151 | return 0; | 159 | return 0; |
152 | } | 160 | } |
@@ -224,6 +232,7 @@ static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup) | |||
224 | unsigned long flags; | 232 | unsigned long flags; |
225 | struct blkio_group *blkg; | 233 | struct blkio_group *blkg; |
226 | void *key; | 234 | void *key; |
235 | struct blkio_policy_type *blkiop; | ||
227 | 236 | ||
228 | rcu_read_lock(); | 237 | rcu_read_lock(); |
229 | remove_entry: | 238 | remove_entry: |
@@ -249,7 +258,10 @@ remove_entry: | |||
249 | * we have more policies in place, we need some dynamic registration | 258 | * we have more policies in place, we need some dynamic registration |
250 | * of callback function. | 259 | * of callback function. |
251 | */ | 260 | */ |
252 | cfq_unlink_blkio_group(key, blkg); | 261 | spin_lock(&blkio_list_lock); |
262 | list_for_each_entry(blkiop, &blkio_list, list) | ||
263 | blkiop->ops.blkio_unlink_group_fn(key, blkg); | ||
264 | spin_unlock(&blkio_list_lock); | ||
253 | goto remove_entry; | 265 | goto remove_entry; |
254 | done: | 266 | done: |
255 | free_css_id(&blkio_subsys, &blkcg->css); | 267 | free_css_id(&blkio_subsys, &blkcg->css); |
@@ -330,3 +342,19 @@ struct cgroup_subsys blkio_subsys = { | |||
330 | .subsys_id = blkio_subsys_id, | 342 | .subsys_id = blkio_subsys_id, |
331 | .use_id = 1, | 343 | .use_id = 1, |
332 | }; | 344 | }; |
345 | |||
346 | void blkio_policy_register(struct blkio_policy_type *blkiop) | ||
347 | { | ||
348 | spin_lock(&blkio_list_lock); | ||
349 | list_add_tail(&blkiop->list, &blkio_list); | ||
350 | spin_unlock(&blkio_list_lock); | ||
351 | } | ||
352 | EXPORT_SYMBOL_GPL(blkio_policy_register); | ||
353 | |||
354 | void blkio_policy_unregister(struct blkio_policy_type *blkiop) | ||
355 | { | ||
356 | spin_lock(&blkio_list_lock); | ||
357 | list_del_init(&blkiop->list); | ||
358 | spin_unlock(&blkio_list_lock); | ||
359 | } | ||
360 | EXPORT_SYMBOL_GPL(blkio_policy_unregister); | ||