summaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-08-18 17:55:31 -0400
committerJens Axboe <axboe@fb.com>2015-08-18 18:49:18 -0400
commit36aa9e5f591e84d67aad2c5bff75e413d77660dd (patch)
tree228d8986be70359b086c30a453d1fc7ee77cfada /block/cfq-iosched.c
parent880f50e228f80626dff6327a6e281e40286f5228 (diff)
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/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index baa8459f7064..ea88d8905bbd 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1747,26 +1747,31 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of,
1747 struct cfq_group *cfqg; 1747 struct cfq_group *cfqg;
1748 struct cfq_group_data *cfqgd; 1748 struct cfq_group_data *cfqgd;
1749 int ret; 1749 int ret;
1750 u64 v;
1750 1751
1751 ret = blkg_conf_prep(blkcg, &blkcg_policy_cfq, buf, &ctx); 1752 ret = blkg_conf_prep(blkcg, &blkcg_policy_cfq, buf, &ctx);
1752 if (ret) 1753 if (ret)
1753 return ret; 1754 return ret;
1754 1755
1756 ret = -EINVAL;
1757 if (sscanf(ctx.body, "%llu", &v) != 1)
1758 goto out_finish;
1759
1755 cfqg = blkg_to_cfqg(ctx.blkg); 1760 cfqg = blkg_to_cfqg(ctx.blkg);
1756 cfqgd = blkcg_to_cfqgd(blkcg); 1761 cfqgd = blkcg_to_cfqgd(blkcg);
1757 1762
1758 ret = -ERANGE; 1763 ret = -ERANGE;
1759 if (!ctx.v || (ctx.v >= CFQ_WEIGHT_MIN && ctx.v <= CFQ_WEIGHT_MAX)) { 1764 if (!v || (v >= CFQ_WEIGHT_MIN && v <= CFQ_WEIGHT_MAX)) {
1760 if (!is_leaf_weight) { 1765 if (!is_leaf_weight) {
1761 cfqg->dev_weight = ctx.v; 1766 cfqg->dev_weight = v;
1762 cfqg->new_weight = ctx.v ?: cfqgd->weight; 1767 cfqg->new_weight = v ?: cfqgd->weight;
1763 } else { 1768 } else {
1764 cfqg->dev_leaf_weight = ctx.v; 1769 cfqg->dev_leaf_weight = v;
1765 cfqg->new_leaf_weight = ctx.v ?: cfqgd->leaf_weight; 1770 cfqg->new_leaf_weight = v ?: cfqgd->leaf_weight;
1766 } 1771 }
1767 ret = 0; 1772 ret = 0;
1768 } 1773 }
1769 1774out_finish:
1770 blkg_conf_finish(&ctx); 1775 blkg_conf_finish(&ctx);
1771 return ret ?: nbytes; 1776 return ret ?: nbytes;
1772} 1777}