diff options
author | Tejun Heo <tj@kernel.org> | 2012-03-05 16:15:04 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-03-06 15:27:22 -0500 |
commit | 035d10b2fa7e5f7e9bf9465dbc39c35affd5ac32 (patch) | |
tree | 6a712eb1b505e8163d28f8709980e581a08b572c /block/blk-cgroup.c | |
parent | ca32aefc7f2539ed88d42763330d54ee3e61769a (diff) |
blkcg: add blkio_policy[] array and allow one policy per policy ID
Block cgroup policies are maintained in a linked list and,
theoretically, multiple policies sharing the same policy ID are
allowed.
This patch temporarily restricts one policy per plid and adds
blkio_policy[] array which indexes registered policy types by plid.
Both the restriction and blkio_policy[] array are transitional and
will be removed once API cleanup is complete.
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.c')
-rw-r--r-- | block/blk-cgroup.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 5e50ca1f5b47..f1b08d3cba55 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -29,6 +29,8 @@ static LIST_HEAD(blkio_list); | |||
29 | struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; | 29 | struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; |
30 | EXPORT_SYMBOL_GPL(blkio_root_cgroup); | 30 | EXPORT_SYMBOL_GPL(blkio_root_cgroup); |
31 | 31 | ||
32 | static struct blkio_policy_type *blkio_policy[BLKIO_NR_POLICIES]; | ||
33 | |||
32 | static struct cgroup_subsys_state *blkiocg_create(struct cgroup_subsys *, | 34 | static struct cgroup_subsys_state *blkiocg_create(struct cgroup_subsys *, |
33 | struct cgroup *); | 35 | struct cgroup *); |
34 | static int blkiocg_can_attach(struct cgroup_subsys *, struct cgroup *, | 36 | static int blkiocg_can_attach(struct cgroup_subsys *, struct cgroup *, |
@@ -1694,7 +1696,11 @@ static void blkiocg_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | |||
1694 | void blkio_policy_register(struct blkio_policy_type *blkiop) | 1696 | void blkio_policy_register(struct blkio_policy_type *blkiop) |
1695 | { | 1697 | { |
1696 | spin_lock(&blkio_list_lock); | 1698 | spin_lock(&blkio_list_lock); |
1699 | |||
1700 | BUG_ON(blkio_policy[blkiop->plid]); | ||
1701 | blkio_policy[blkiop->plid] = blkiop; | ||
1697 | list_add_tail(&blkiop->list, &blkio_list); | 1702 | list_add_tail(&blkiop->list, &blkio_list); |
1703 | |||
1698 | spin_unlock(&blkio_list_lock); | 1704 | spin_unlock(&blkio_list_lock); |
1699 | } | 1705 | } |
1700 | EXPORT_SYMBOL_GPL(blkio_policy_register); | 1706 | EXPORT_SYMBOL_GPL(blkio_policy_register); |
@@ -1702,7 +1708,11 @@ EXPORT_SYMBOL_GPL(blkio_policy_register); | |||
1702 | void blkio_policy_unregister(struct blkio_policy_type *blkiop) | 1708 | void blkio_policy_unregister(struct blkio_policy_type *blkiop) |
1703 | { | 1709 | { |
1704 | spin_lock(&blkio_list_lock); | 1710 | spin_lock(&blkio_list_lock); |
1711 | |||
1712 | BUG_ON(blkio_policy[blkiop->plid] != blkiop); | ||
1713 | blkio_policy[blkiop->plid] = NULL; | ||
1705 | list_del_init(&blkiop->list); | 1714 | list_del_init(&blkiop->list); |
1715 | |||
1706 | spin_unlock(&blkio_list_lock); | 1716 | spin_unlock(&blkio_list_lock); |
1707 | } | 1717 | } |
1708 | EXPORT_SYMBOL_GPL(blkio_policy_unregister); | 1718 | EXPORT_SYMBOL_GPL(blkio_policy_unregister); |