summaryrefslogtreecommitdiffstats
path: root/block/blk-throttle.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-08-18 14:55:31 -0700
committerJens Axboe <axboe@fb.com>2015-08-18 15:49:18 -0700
commit36aa9e5f591e84d67aad2c5bff75e413d77660dd (patch)
tree228d8986be70359b086c30a453d1fc7ee77cfada /block/blk-throttle.c
parent880f50e228f80626dff6327a6e281e40286f5228 (diff)
downloadlinux-36aa9e5f591e84d67aad2c5bff75e413d77660dd.tar.bz2
blkcg: move body parsing from blkg_conf_prep() to its callers
Currently, blkg_conf_prep() expects input to be of the following form MAJ:MIN NUM and reads the NUM part into blkg_conf_ctx->v. This is quite restrictive and gets in the way in implementing blkcg interface for the unified hierarchy. This patch updates blkg_conf_prep() so that it expects MAJ:MIN BODY_STR where BODY_STR is an arbitrary string. blkg_conf_ctx->v is replaced with ->body which is a char pointer pointing to the start of BODY_STR. Parsing of the body is moved to blkg_conf_prep()'s callers. To allow using, for example, strsep() on blkg_conf_ctx->val, it is a non-const pointer and to accommodate that const is dropped from @input too. This doesn't cause any behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-throttle.c')
-rw-r--r--block/blk-throttle.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 8b4f6b81bb72..0e17c8f92d25 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -1154,21 +1154,25 @@ static ssize_t tg_set_conf(struct kernfs_open_file *of,
struct blkcg_gq *blkg;
struct cgroup_subsys_state *pos_css;
int ret;
+ u64 v;
ret = blkg_conf_prep(blkcg, &blkcg_policy_throtl, buf, &ctx);
if (ret)
return ret;
+ ret = -EINVAL;
+ if (sscanf(ctx.body, "%llu", &v) != 1)
+ goto out_finish;
+ if (!v)
+ v = -1;
+
tg = blkg_to_tg(ctx.blkg);
sq = &tg->service_queue;
- if (!ctx.v)
- ctx.v = -1;
-
if (is_u64)
- *(u64 *)((void *)tg + of_cft(of)->private) = ctx.v;
+ *(u64 *)((void *)tg + of_cft(of)->private) = v;
else
- *(unsigned int *)((void *)tg + of_cft(of)->private) = ctx.v;
+ *(unsigned int *)((void *)tg + of_cft(of)->private) = v;
throtl_log(&tg->service_queue,
"limit change rbps=%llu wbps=%llu riops=%u wiops=%u",
@@ -1201,8 +1205,10 @@ static ssize_t tg_set_conf(struct kernfs_open_file *of,
throtl_schedule_next_dispatch(sq->parent_sq, true);
}
+ ret = 0;
+out_finish:
blkg_conf_finish(&ctx);
- return nbytes;
+ return ret ?: nbytes;
}
static ssize_t tg_set_conf_u64(struct kernfs_open_file *of,