aboutsummaryrefslogtreecommitdiff
path: root/block/blk-throttle.c
diff options
context:
space:
mode:
authorTejun Heo2012-04-13 13:11:33 -0700
committerJens Axboe2012-04-20 10:06:06 +0200
commita2b1693bac45ea3fe3ba612fd22c45f17449f610 (patch)
tree2e05859caab6453efbc85d584dd72dca7ef03cd0 /block/blk-throttle.c
parent03d8e11142a893ad322285d3c8a08e88b570cda1 (diff)
blkcg: implement per-queue policy activation
All blkcg policies were assumed to be enabled on all request_queues. Due to various implementation obstacles, during the recent blkcg core updates, this was temporarily implemented as shooting down all !root blkgs on elevator switch and policy [de]registration combined with half-broken in-place root blkg updates. In addition to being buggy and racy, this meant losing all blkcg configurations across those events. Now that blkcg is cleaned up enough, this patch replaces the temporary implementation with proper per-queue policy activation. Each blkcg policy should call the new blkcg_[de]activate_policy() to enable and disable the policy on a specific queue. blkcg_activate_policy() allocates and installs policy data for the policy for all existing blkgs. blkcg_deactivate_policy() does the reverse. If a policy is not enabled for a given queue, blkg printing / config functions skip the respective blkg for the queue. blkcg_activate_policy() also takes care of root blkg creation, and cfq_init_queue() and blk_throtl_init() are updated accordingly. This replaces blkcg_bypass_{start|end}() and update_root_blkg_pd() unnecessary. Dropped. v2: cfq_init_queue() was returning uninitialized @ret on root_group alloc failure if !CONFIG_CFQ_GROUP_IOSCHED. Fixed. 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-throttle.c')
-rw-r--r--block/blk-throttle.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 8c520fad6885..2fc964e06ea4 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -995,35 +995,31 @@ static int tg_set_conf(struct cgroup *cgrp, struct cftype *cft, const char *buf,
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
struct blkg_conf_ctx ctx;
struct throtl_grp *tg;
+ struct throtl_data *td;
int ret;
ret = blkg_conf_prep(blkcg, &blkio_policy_throtl, buf, &ctx);
if (ret)
return ret;
- ret = -EINVAL;
tg = blkg_to_tg(ctx.blkg);
- if (tg) {
- struct throtl_data *td = ctx.blkg->q->td;
-
- if (!ctx.v)
- ctx.v = -1;
+ td = ctx.blkg->q->td;
- if (is_u64)
- *(u64 *)((void *)tg + cft->private) = ctx.v;
- else
- *(unsigned int *)((void *)tg + cft->private) = ctx.v;
+ if (!ctx.v)
+ ctx.v = -1;
- /* XXX: we don't need the following deferred processing */
- xchg(&tg->limits_changed, true);
- xchg(&td->limits_changed, true);
- throtl_schedule_delayed_work(td, 0);
+ if (is_u64)
+ *(u64 *)((void *)tg + cft->private) = ctx.v;
+ else
+ *(unsigned int *)((void *)tg + cft->private) = ctx.v;
- ret = 0;
- }
+ /* XXX: we don't need the following deferred processing */
+ xchg(&tg->limits_changed, true);
+ xchg(&td->limits_changed, true);
+ throtl_schedule_delayed_work(td, 0);
blkg_conf_finish(&ctx);
- return ret;
+ return 0;
}
static int tg_set_conf_u64(struct cgroup *cgrp, struct cftype *cft,
@@ -1230,7 +1226,7 @@ void blk_throtl_drain(struct request_queue *q)
int blk_throtl_init(struct request_queue *q)
{
struct throtl_data *td;
- struct blkio_group *blkg;
+ int ret;
td = kzalloc_node(sizeof(*td), GFP_KERNEL, q->node);
if (!td)
@@ -1243,28 +1239,18 @@ int blk_throtl_init(struct request_queue *q)
q->td = td;
td->queue = q;
- /* alloc and init root group. */
- rcu_read_lock();
- spin_lock_irq(q->queue_lock);
-
- blkg = blkg_lookup_create(&blkio_root_cgroup, q, true);
- if (!IS_ERR(blkg))
- q->root_blkg = blkg;
-
- spin_unlock_irq(q->queue_lock);
- rcu_read_unlock();
-
- if (!q->root_blkg) {
+ /* activate policy */
+ ret = blkcg_activate_policy(q, &blkio_policy_throtl);
+ if (ret)
kfree(td);
- return -ENOMEM;
- }
- return 0;
+ return ret;
}
void blk_throtl_exit(struct request_queue *q)
{
BUG_ON(!q->td);
throtl_shutdown_wq(q);
+ blkcg_deactivate_policy(q, &blkio_policy_throtl);
kfree(q->td);
}