diff options
-rw-r--r-- | block/blk-cgroup.c | 156 | ||||
-rw-r--r-- | block/blk-cgroup.h | 3 |
2 files changed, 55 insertions, 104 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 13cae77e8bf6..a9723a8dc983 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -1115,95 +1115,28 @@ static int blkiocg_file_write(struct cgroup *cgrp, struct cftype *cft, | |||
1115 | return ret; | 1115 | return ret; |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | static void blkio_print_group_conf(struct cftype *cft, struct blkio_group *blkg, | 1118 | /* for propio conf */ |
1119 | struct seq_file *m) | 1119 | static u64 blkg_prfill_weight_device(struct seq_file *sf, |
1120 | struct blkg_policy_data *pd, int off) | ||
1120 | { | 1121 | { |
1121 | int plid = BLKIOFILE_POLICY(cft->private); | 1122 | if (!pd->conf.weight) |
1122 | int fileid = BLKIOFILE_ATTR(cft->private); | 1123 | return 0; |
1123 | struct blkg_policy_data *pd = blkg->pd[plid]; | 1124 | return __blkg_prfill_u64(sf, pd, pd->conf.weight); |
1124 | const char *dname = blkg_dev_name(blkg); | ||
1125 | int rw = WRITE; | ||
1126 | |||
1127 | if (!dname) | ||
1128 | return; | ||
1129 | |||
1130 | switch (plid) { | ||
1131 | case BLKIO_POLICY_PROP: | ||
1132 | if (pd->conf.weight) | ||
1133 | seq_printf(m, "%s\t%u\n", | ||
1134 | dname, pd->conf.weight); | ||
1135 | break; | ||
1136 | case BLKIO_POLICY_THROTL: | ||
1137 | switch (fileid) { | ||
1138 | case BLKIO_THROTL_read_bps_device: | ||
1139 | rw = READ; | ||
1140 | case BLKIO_THROTL_write_bps_device: | ||
1141 | if (pd->conf.bps[rw]) | ||
1142 | seq_printf(m, "%s\t%llu\n", | ||
1143 | dname, pd->conf.bps[rw]); | ||
1144 | break; | ||
1145 | case BLKIO_THROTL_read_iops_device: | ||
1146 | rw = READ; | ||
1147 | case BLKIO_THROTL_write_iops_device: | ||
1148 | if (pd->conf.iops[rw]) | ||
1149 | seq_printf(m, "%s\t%u\n", | ||
1150 | dname, pd->conf.iops[rw]); | ||
1151 | break; | ||
1152 | } | ||
1153 | break; | ||
1154 | default: | ||
1155 | BUG(); | ||
1156 | } | ||
1157 | } | 1125 | } |
1158 | 1126 | ||
1159 | /* cgroup files which read their data from policy nodes end up here */ | 1127 | static int blkcg_print_weight_device(struct cgroup *cgrp, struct cftype *cft, |
1160 | static void blkio_read_conf(struct cftype *cft, struct blkio_cgroup *blkcg, | 1128 | struct seq_file *sf) |
1161 | struct seq_file *m) | ||
1162 | { | 1129 | { |
1163 | struct blkio_group *blkg; | 1130 | blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp), |
1164 | struct hlist_node *n; | 1131 | blkg_prfill_weight_device, BLKIO_POLICY_PROP, 0, |
1165 | 1132 | false); | |
1166 | spin_lock_irq(&blkcg->lock); | 1133 | return 0; |
1167 | hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) | ||
1168 | blkio_print_group_conf(cft, blkg, m); | ||
1169 | spin_unlock_irq(&blkcg->lock); | ||
1170 | } | 1134 | } |
1171 | 1135 | ||
1172 | static int blkiocg_file_read(struct cgroup *cgrp, struct cftype *cft, | 1136 | static int blkcg_print_weight(struct cgroup *cgrp, struct cftype *cft, |
1173 | struct seq_file *m) | 1137 | struct seq_file *sf) |
1174 | { | 1138 | { |
1175 | struct blkio_cgroup *blkcg; | 1139 | seq_printf(sf, "%u\n", cgroup_to_blkio_cgroup(cgrp)->weight); |
1176 | enum blkio_policy_id plid = BLKIOFILE_POLICY(cft->private); | ||
1177 | int name = BLKIOFILE_ATTR(cft->private); | ||
1178 | |||
1179 | blkcg = cgroup_to_blkio_cgroup(cgrp); | ||
1180 | |||
1181 | switch(plid) { | ||
1182 | case BLKIO_POLICY_PROP: | ||
1183 | switch(name) { | ||
1184 | case BLKIO_PROP_weight_device: | ||
1185 | blkio_read_conf(cft, blkcg, m); | ||
1186 | return 0; | ||
1187 | default: | ||
1188 | BUG(); | ||
1189 | } | ||
1190 | break; | ||
1191 | case BLKIO_POLICY_THROTL: | ||
1192 | switch(name){ | ||
1193 | case BLKIO_THROTL_read_bps_device: | ||
1194 | case BLKIO_THROTL_write_bps_device: | ||
1195 | case BLKIO_THROTL_read_iops_device: | ||
1196 | case BLKIO_THROTL_write_iops_device: | ||
1197 | blkio_read_conf(cft, blkcg, m); | ||
1198 | return 0; | ||
1199 | default: | ||
1200 | BUG(); | ||
1201 | } | ||
1202 | break; | ||
1203 | default: | ||
1204 | BUG(); | ||
1205 | } | ||
1206 | |||
1207 | return 0; | 1140 | return 0; |
1208 | } | 1141 | } |
1209 | 1142 | ||
@@ -1233,40 +1166,59 @@ static int blkcg_set_weight(struct cgroup *cgrp, struct cftype *cft, u64 val) | |||
1233 | return 0; | 1166 | return 0; |
1234 | } | 1167 | } |
1235 | 1168 | ||
1236 | static u64 blkiocg_file_read_u64 (struct cgroup *cgrp, struct cftype *cft) { | 1169 | /* for blk-throttle conf */ |
1237 | struct blkio_cgroup *blkcg; | 1170 | #ifdef CONFIG_BLK_DEV_THROTTLING |
1238 | enum blkio_policy_id plid = BLKIOFILE_POLICY(cft->private); | 1171 | static u64 blkg_prfill_conf_u64(struct seq_file *sf, |
1239 | int name = BLKIOFILE_ATTR(cft->private); | 1172 | struct blkg_policy_data *pd, int off) |
1173 | { | ||
1174 | u64 v = *(u64 *)((void *)&pd->conf + off); | ||
1240 | 1175 | ||
1241 | blkcg = cgroup_to_blkio_cgroup(cgrp); | 1176 | if (!v) |
1177 | return 0; | ||
1178 | return __blkg_prfill_u64(sf, pd, v); | ||
1179 | } | ||
1242 | 1180 | ||
1243 | switch(plid) { | 1181 | static int blkcg_print_conf_u64(struct cgroup *cgrp, struct cftype *cft, |
1244 | case BLKIO_POLICY_PROP: | 1182 | struct seq_file *sf) |
1245 | switch(name) { | 1183 | { |
1246 | case BLKIO_PROP_weight: | 1184 | int off; |
1247 | return (u64)blkcg->weight; | 1185 | |
1248 | } | 1186 | switch (BLKIOFILE_ATTR(cft->private)) { |
1187 | case BLKIO_THROTL_read_bps_device: | ||
1188 | off = offsetof(struct blkio_group_conf, bps[READ]); | ||
1189 | break; | ||
1190 | case BLKIO_THROTL_write_bps_device: | ||
1191 | off = offsetof(struct blkio_group_conf, bps[WRITE]); | ||
1192 | break; | ||
1193 | case BLKIO_THROTL_read_iops_device: | ||
1194 | off = offsetof(struct blkio_group_conf, iops[READ]); | ||
1195 | break; | ||
1196 | case BLKIO_THROTL_write_iops_device: | ||
1197 | off = offsetof(struct blkio_group_conf, iops[WRITE]); | ||
1249 | break; | 1198 | break; |
1250 | default: | 1199 | default: |
1251 | BUG(); | 1200 | return -EINVAL; |
1252 | } | 1201 | } |
1202 | |||
1203 | blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp), | ||
1204 | blkg_prfill_conf_u64, BLKIO_POLICY_THROTL, | ||
1205 | off, false); | ||
1253 | return 0; | 1206 | return 0; |
1254 | } | 1207 | } |
1208 | #endif | ||
1255 | 1209 | ||
1256 | struct cftype blkio_files[] = { | 1210 | struct cftype blkio_files[] = { |
1257 | { | 1211 | { |
1258 | .name = "weight_device", | 1212 | .name = "weight_device", |
1259 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_PROP, | 1213 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_PROP, |
1260 | BLKIO_PROP_weight_device), | 1214 | BLKIO_PROP_weight_device), |
1261 | .read_seq_string = blkiocg_file_read, | 1215 | .read_seq_string = blkcg_print_weight_device, |
1262 | .write_string = blkiocg_file_write, | 1216 | .write_string = blkiocg_file_write, |
1263 | .max_write_len = 256, | 1217 | .max_write_len = 256, |
1264 | }, | 1218 | }, |
1265 | { | 1219 | { |
1266 | .name = "weight", | 1220 | .name = "weight", |
1267 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_PROP, | 1221 | .read_seq_string = blkcg_print_weight, |
1268 | BLKIO_PROP_weight), | ||
1269 | .read_u64 = blkiocg_file_read_u64, | ||
1270 | .write_u64 = blkcg_set_weight, | 1222 | .write_u64 = blkcg_set_weight, |
1271 | }, | 1223 | }, |
1272 | { | 1224 | { |
@@ -1326,7 +1278,7 @@ struct cftype blkio_files[] = { | |||
1326 | .name = "throttle.read_bps_device", | 1278 | .name = "throttle.read_bps_device", |
1327 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, | 1279 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, |
1328 | BLKIO_THROTL_read_bps_device), | 1280 | BLKIO_THROTL_read_bps_device), |
1329 | .read_seq_string = blkiocg_file_read, | 1281 | .read_seq_string = blkcg_print_conf_u64, |
1330 | .write_string = blkiocg_file_write, | 1282 | .write_string = blkiocg_file_write, |
1331 | .max_write_len = 256, | 1283 | .max_write_len = 256, |
1332 | }, | 1284 | }, |
@@ -1335,7 +1287,7 @@ struct cftype blkio_files[] = { | |||
1335 | .name = "throttle.write_bps_device", | 1287 | .name = "throttle.write_bps_device", |
1336 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, | 1288 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, |
1337 | BLKIO_THROTL_write_bps_device), | 1289 | BLKIO_THROTL_write_bps_device), |
1338 | .read_seq_string = blkiocg_file_read, | 1290 | .read_seq_string = blkcg_print_conf_u64, |
1339 | .write_string = blkiocg_file_write, | 1291 | .write_string = blkiocg_file_write, |
1340 | .max_write_len = 256, | 1292 | .max_write_len = 256, |
1341 | }, | 1293 | }, |
@@ -1344,7 +1296,7 @@ struct cftype blkio_files[] = { | |||
1344 | .name = "throttle.read_iops_device", | 1296 | .name = "throttle.read_iops_device", |
1345 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, | 1297 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, |
1346 | BLKIO_THROTL_read_iops_device), | 1298 | BLKIO_THROTL_read_iops_device), |
1347 | .read_seq_string = blkiocg_file_read, | 1299 | .read_seq_string = blkcg_print_conf_u64, |
1348 | .write_string = blkiocg_file_write, | 1300 | .write_string = blkiocg_file_write, |
1349 | .max_write_len = 256, | 1301 | .max_write_len = 256, |
1350 | }, | 1302 | }, |
@@ -1353,7 +1305,7 @@ struct cftype blkio_files[] = { | |||
1353 | .name = "throttle.write_iops_device", | 1305 | .name = "throttle.write_iops_device", |
1354 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, | 1306 | .private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL, |
1355 | BLKIO_THROTL_write_iops_device), | 1307 | BLKIO_THROTL_write_iops_device), |
1356 | .read_seq_string = blkiocg_file_read, | 1308 | .read_seq_string = blkcg_print_conf_u64, |
1357 | .write_string = blkiocg_file_write, | 1309 | .write_string = blkiocg_file_write, |
1358 | .max_write_len = 256, | 1310 | .max_write_len = 256, |
1359 | }, | 1311 | }, |
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index 7331d7965a5e..b67eefa706c3 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
@@ -52,7 +52,6 @@ enum blkg_state_flags { | |||
52 | 52 | ||
53 | /* cgroup files owned by proportional weight policy */ | 53 | /* cgroup files owned by proportional weight policy */ |
54 | enum blkcg_file_name_prop { | 54 | enum blkcg_file_name_prop { |
55 | BLKIO_PROP_weight = 1, | ||
56 | BLKIO_PROP_weight_device, | 55 | BLKIO_PROP_weight_device, |
57 | }; | 56 | }; |
58 | 57 | ||
@@ -130,7 +129,7 @@ struct blkio_group_stats_cpu { | |||
130 | 129 | ||
131 | struct blkio_group_conf { | 130 | struct blkio_group_conf { |
132 | unsigned int weight; | 131 | unsigned int weight; |
133 | unsigned int iops[2]; | 132 | u64 iops[2]; |
134 | u64 bps[2]; | 133 | u64 bps[2]; |
135 | }; | 134 | }; |
136 | 135 | ||