X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=block%2Fblk-cgroup.c;h=c85d74cae200275b168f5291770073ad3540347f;hb=53c583d2269851de9df1c2e992cb2f7f124a5f55;hp=4d4a277b2905de7bef24e8eb126f08df63284702;hpb=9d6a986c0b276085f7944cd8ad65f4f82aff7536;p=safe%2Fjmp%2Flinux-2.6 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 4d4a277..c85d74c 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -14,26 +14,15 @@ #include #include #include +#include #include "blk-cgroup.h" -#include "cfq-iosched.h" + +static DEFINE_SPINLOCK(blkio_list_lock); +static LIST_HEAD(blkio_list); struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; EXPORT_SYMBOL_GPL(blkio_root_cgroup); -bool blkiocg_css_tryget(struct blkio_cgroup *blkcg) -{ - if (!css_tryget(&blkcg->css)) - return false; - return true; -} -EXPORT_SYMBOL_GPL(blkiocg_css_tryget); - -void blkiocg_css_put(struct blkio_cgroup *blkcg) -{ - css_put(&blkcg->css); -} -EXPORT_SYMBOL_GPL(blkiocg_css_put); - struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return container_of(cgroup_subsys_state(cgroup, blkio_subsys_id), @@ -138,16 +127,22 @@ blkiocg_weight_write(struct cgroup *cgroup, struct cftype *cftype, u64 val) struct blkio_cgroup *blkcg; struct blkio_group *blkg; struct hlist_node *n; + struct blkio_policy_type *blkiop; if (val < BLKIO_WEIGHT_MIN || val > BLKIO_WEIGHT_MAX) return -EINVAL; blkcg = cgroup_to_blkio_cgroup(cgroup); + spin_lock(&blkio_list_lock); spin_lock_irq(&blkcg->lock); blkcg->weight = (unsigned int)val; - hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) - cfq_update_blkio_group_weight(blkg, blkcg->weight); + hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) { + list_for_each_entry(blkiop, &blkio_list, list) + blkiop->ops.blkio_update_group_weight_fn(blkg, + blkcg->weight); + } spin_unlock_irq(&blkcg->lock); + spin_unlock(&blkio_list_lock); return 0; } @@ -224,6 +219,7 @@ static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup) unsigned long flags; struct blkio_group *blkg; void *key; + struct blkio_policy_type *blkiop; rcu_read_lock(); remove_entry: @@ -249,7 +245,10 @@ remove_entry: * we have more policies in place, we need some dynamic registration * of callback function. */ - cfq_unlink_blkio_group(key, blkg); + spin_lock(&blkio_list_lock); + list_for_each_entry(blkiop, &blkio_list, list) + blkiop->ops.blkio_unlink_group_fn(key, blkg); + spin_unlock(&blkio_list_lock); goto remove_entry; done: free_css_id(&blkio_subsys, &blkcg->css); @@ -330,3 +329,19 @@ struct cgroup_subsys blkio_subsys = { .subsys_id = blkio_subsys_id, .use_id = 1, }; + +void blkio_policy_register(struct blkio_policy_type *blkiop) +{ + spin_lock(&blkio_list_lock); + list_add_tail(&blkiop->list, &blkio_list); + spin_unlock(&blkio_list_lock); +} +EXPORT_SYMBOL_GPL(blkio_policy_register); + +void blkio_policy_unregister(struct blkio_policy_type *blkiop) +{ + spin_lock(&blkio_list_lock); + list_del_init(&blkiop->list); + spin_unlock(&blkio_list_lock); +} +EXPORT_SYMBOL_GPL(blkio_policy_unregister);