diff options
author | Tejun Heo <tj@kernel.org> | 2015-08-18 17:55:32 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-08-18 18:49:18 -0400 |
commit | 69948b070ee2bc3cc253e862cbe2bb09b173d7bd (patch) | |
tree | c32f9439d234f7325c7de5c24aba5e97bcde0d70 /block/blk-throttle.c | |
parent | 36aa9e5f591e84d67aad2c5bff75e413d77660dd (diff) |
blkcg: separate out tg_conf_updated() from tg_set_conf()
tg_set_conf() is largely consisted of parsing and setting the new
config and the follow-up application and propagation. This patch
separates out the latter part into tg_conf_updated(). This will be
used to implement interface for the unified hierarchy.
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.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 0e17c8f92d25..a8bb2fd8f523 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
@@ -1144,35 +1144,11 @@ static int tg_print_conf_uint(struct seq_file *sf, void *v) | |||
1144 | return 0; | 1144 | return 0; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | static ssize_t tg_set_conf(struct kernfs_open_file *of, | 1147 | static void tg_conf_updated(struct throtl_grp *tg) |
1148 | char *buf, size_t nbytes, loff_t off, bool is_u64) | ||
1149 | { | 1148 | { |
1150 | struct blkcg *blkcg = css_to_blkcg(of_css(of)); | 1149 | struct throtl_service_queue *sq = &tg->service_queue; |
1151 | struct blkg_conf_ctx ctx; | ||
1152 | struct throtl_grp *tg; | ||
1153 | struct throtl_service_queue *sq; | ||
1154 | struct blkcg_gq *blkg; | ||
1155 | struct cgroup_subsys_state *pos_css; | 1150 | struct cgroup_subsys_state *pos_css; |
1156 | int ret; | 1151 | struct blkcg_gq *blkg; |
1157 | u64 v; | ||
1158 | |||
1159 | ret = blkg_conf_prep(blkcg, &blkcg_policy_throtl, buf, &ctx); | ||
1160 | if (ret) | ||
1161 | return ret; | ||
1162 | |||
1163 | ret = -EINVAL; | ||
1164 | if (sscanf(ctx.body, "%llu", &v) != 1) | ||
1165 | goto out_finish; | ||
1166 | if (!v) | ||
1167 | v = -1; | ||
1168 | |||
1169 | tg = blkg_to_tg(ctx.blkg); | ||
1170 | sq = &tg->service_queue; | ||
1171 | |||
1172 | if (is_u64) | ||
1173 | *(u64 *)((void *)tg + of_cft(of)->private) = v; | ||
1174 | else | ||
1175 | *(unsigned int *)((void *)tg + of_cft(of)->private) = v; | ||
1176 | 1152 | ||
1177 | throtl_log(&tg->service_queue, | 1153 | throtl_log(&tg->service_queue, |
1178 | "limit change rbps=%llu wbps=%llu riops=%u wiops=%u", | 1154 | "limit change rbps=%llu wbps=%llu riops=%u wiops=%u", |
@@ -1186,7 +1162,7 @@ static ssize_t tg_set_conf(struct kernfs_open_file *of, | |||
1186 | * restrictions in the whole hierarchy and allows them to bypass | 1162 | * restrictions in the whole hierarchy and allows them to bypass |
1187 | * blk-throttle. | 1163 | * blk-throttle. |
1188 | */ | 1164 | */ |
1189 | blkg_for_each_descendant_pre(blkg, pos_css, ctx.blkg) | 1165 | blkg_for_each_descendant_pre(blkg, pos_css, tg_to_blkg(tg)) |
1190 | tg_update_has_rules(blkg_to_tg(blkg)); | 1166 | tg_update_has_rules(blkg_to_tg(blkg)); |
1191 | 1167 | ||
1192 | /* | 1168 | /* |
@@ -1204,7 +1180,35 @@ static ssize_t tg_set_conf(struct kernfs_open_file *of, | |||
1204 | tg_update_disptime(tg); | 1180 | tg_update_disptime(tg); |
1205 | throtl_schedule_next_dispatch(sq->parent_sq, true); | 1181 | throtl_schedule_next_dispatch(sq->parent_sq, true); |
1206 | } | 1182 | } |
1183 | } | ||
1184 | |||
1185 | static ssize_t tg_set_conf(struct kernfs_open_file *of, | ||
1186 | char *buf, size_t nbytes, loff_t off, bool is_u64) | ||
1187 | { | ||
1188 | struct blkcg *blkcg = css_to_blkcg(of_css(of)); | ||
1189 | struct blkg_conf_ctx ctx; | ||
1190 | struct throtl_grp *tg; | ||
1191 | int ret; | ||
1192 | u64 v; | ||
1193 | |||
1194 | ret = blkg_conf_prep(blkcg, &blkcg_policy_throtl, buf, &ctx); | ||
1195 | if (ret) | ||
1196 | return ret; | ||
1197 | |||
1198 | ret = -EINVAL; | ||
1199 | if (sscanf(ctx.body, "%llu", &v) != 1) | ||
1200 | goto out_finish; | ||
1201 | if (!v) | ||
1202 | v = -1; | ||
1203 | |||
1204 | tg = blkg_to_tg(ctx.blkg); | ||
1205 | |||
1206 | if (is_u64) | ||
1207 | *(u64 *)((void *)tg + of_cft(of)->private) = v; | ||
1208 | else | ||
1209 | *(unsigned int *)((void *)tg + of_cft(of)->private) = v; | ||
1207 | 1210 | ||
1211 | tg_conf_updated(tg); | ||
1208 | ret = 0; | 1212 | ret = 0; |
1209 | out_finish: | 1213 | out_finish: |
1210 | blkg_conf_finish(&ctx); | 1214 | blkg_conf_finish(&ctx); |