f2fs: print type for each segment in segment_info's show
The original segment_info's show looks out-of-format:
cat /proc/fs/f2fs/loop0/segment_info
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 512
512 512 512 512 512 512 512 0 0 512
348 0 263 0 0 512 0 0 512 512
512 512 0 512 512 512 512 512 512 512
512 512 511 328 512 512 512 512 512 512
512 512 512 512 512 512 512 0 0 175
Let's fix this and show type for each segment.
cat /proc/fs/f2fs/loop0/segment_info
format: segment_type|valid_blocks
segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)
0 2|0 1|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0
10 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0
20 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0
30 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0
40 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0
50 3|0 3|0 3|0 3|0 3|0 3|0 3|0 0|0 3|0 3|0
60 3|0 3|0 3|0 3|0 3|0 3|0 3|0 3|0 3|0 3|512
70 3|512 3|512 3|512 3|512 3|512 3|512 3|512 3|0 3|0 3|512
80 3|0 3|0 3|0 3|0 3|0 3|512 3|0 3|0 3|512 3|512
90 3|512 0|512 3|274 0|512 0|512 0|512 0|512 0|512 0|512 3|512
100 3|512 0|512 3|511 0|328 3|512 0|512 0|512 3|512 0|512 0|512
110 0|512 0|512 0|512 0|512 0|512 0|512 0|512 5|0 4|0 3|512
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3a51d7a..057a3ef 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -544,8 +544,16 @@
le32_to_cpu(sbi->raw_super->segment_count_main);
int i;
+ seq_puts(seq, "format: segment_type|valid_blocks\n"
+ "segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)\n");
+
for (i = 0; i < total_segs; i++) {
- seq_printf(seq, "%u", get_valid_blocks(sbi, i, 1));
+ struct seg_entry *se = get_seg_entry(sbi, i);
+
+ if ((i % 10) == 0)
+ seq_printf(seq, "%-5d", i);
+ seq_printf(seq, "%d|%-3u", se->type,
+ get_valid_blocks(sbi, i, 1));
if ((i % 10) == 9 || i == (total_segs - 1))
seq_putc(seq, '\n');
else