Commit cf1b6d4
md: simplify md_seq_ops
Before this patch, the implementation is hacky and hard to understand:
1) md_seq_start set pos to 1;
2) md_seq_show found pos is 1, then print Personalities;
3) md_seq_next found pos is 1, then it update pos to the first mddev;
4) md_seq_show found pos is not 1 or 2, show mddev;
5) md_seq_next found pos is not 1 or 2, update pos to next mddev;
6) loop 4-5 until the last mddev, then md_seq_next update pos to 2;
7) md_seq_show found pos is 2, then print unused devices;
8) md_seq_next found pos is 2, stop;
This patch remove the magic value and use seq_list_start/next/stop()
directly, and move printing "Personalities" to md_seq_start(),
"unsed devices" to md_seq_stop():
1) md_seq_start print Personalities, and then set pos to first mddev;
2) md_seq_show show mddev;
3) md_seq_next update pos to next mddev;
4) loop 2-3 until the last mddev;
5) md_seq_stop print unsed devices;
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230927061241.1552837-3-yukuai1@huaweicloud.com1 parent 3d8d328 commit cf1b6d4
1 file changed
Lines changed: 22 additions & 78 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8213 | 8213 | | |
8214 | 8214 | | |
8215 | 8215 | | |
| 8216 | + | |
8216 | 8217 | | |
8217 | | - | |
8218 | | - | |
8219 | | - | |
| 8218 | + | |
8220 | 8219 | | |
8221 | | - | |
8222 | | - | |
8223 | | - | |
8224 | | - | |
8225 | | - | |
8226 | | - | |
8227 | | - | |
8228 | | - | |
8229 | | - | |
| 8220 | + | |
| 8221 | + | |
| 8222 | + | |
| 8223 | + | |
| 8224 | + | |
| 8225 | + | |
| 8226 | + | |
| 8227 | + | |
8230 | 8228 | | |
8231 | 8229 | | |
8232 | | - | |
8233 | | - | |
8234 | | - | |
8235 | | - | |
8236 | | - | |
8237 | | - | |
8238 | | - | |
8239 | | - | |
8240 | | - | |
8241 | | - | |
8242 | | - | |
8243 | | - | |
| 8230 | + | |
| 8231 | + | |
8244 | 8232 | | |
8245 | 8233 | | |
8246 | 8234 | | |
8247 | 8235 | | |
8248 | | - | |
8249 | | - | |
8250 | | - | |
8251 | | - | |
8252 | | - | |
8253 | | - | |
8254 | | - | |
8255 | | - | |
8256 | | - | |
8257 | | - | |
8258 | | - | |
8259 | | - | |
8260 | | - | |
8261 | | - | |
8262 | | - | |
8263 | | - | |
8264 | | - | |
8265 | | - | |
8266 | | - | |
8267 | | - | |
8268 | | - | |
8269 | | - | |
8270 | | - | |
8271 | | - | |
8272 | | - | |
8273 | | - | |
8274 | | - | |
8275 | | - | |
8276 | | - | |
8277 | | - | |
8278 | | - | |
8279 | | - | |
8280 | | - | |
8281 | | - | |
| 8236 | + | |
8282 | 8237 | | |
8283 | 8238 | | |
8284 | 8239 | | |
| 8240 | + | |
8285 | 8241 | | |
8286 | | - | |
8287 | | - | |
8288 | | - | |
8289 | | - | |
| 8242 | + | |
| 8243 | + | |
8290 | 8244 | | |
8291 | 8245 | | |
8292 | 8246 | | |
8293 | 8247 | | |
8294 | | - | |
| 8248 | + | |
8295 | 8249 | | |
8296 | 8250 | | |
8297 | 8251 | | |
8298 | | - | |
8299 | | - | |
8300 | | - | |
8301 | | - | |
8302 | | - | |
8303 | | - | |
8304 | | - | |
8305 | | - | |
8306 | | - | |
8307 | | - | |
| 8252 | + | |
8308 | 8253 | | |
8309 | | - | |
8310 | | - | |
8311 | | - | |
8312 | | - | |
8313 | | - | |
8314 | 8254 | | |
| 8255 | + | |
8315 | 8256 | | |
8316 | 8257 | | |
8317 | 8258 | | |
| |||
8382 | 8323 | | |
8383 | 8324 | | |
8384 | 8325 | | |
| 8326 | + | |
| 8327 | + | |
| 8328 | + | |
8385 | 8329 | | |
8386 | 8330 | | |
8387 | 8331 | | |
| |||
0 commit comments