diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-04-27 16:29:05 -0700 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-05-07 10:32:19 -0700 |
commit | f00d6fa727a4c4977241bd21910cafc139f77989 (patch) | |
tree | 3585063cb9f002e8b857f617ae00b10aebf937d5 | |
parent | b7a15f3dbe3f3d009360273b62a633e47a1a65d6 (diff) | |
download | linux-f00d6fa727a4c4977241bd21910cafc139f77989.tar.bz2 |
f2fs: add proc entry to show valid block bitmap
This patch adds a new proc entry to show segment information in more detail.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/super.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index b006de60e99b..90d4b864590c 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -539,6 +539,7 @@ static void f2fs_put_super(struct super_block *sb) if (sbi->s_proc) { remove_proc_entry("segment_info", sbi->s_proc); + remove_proc_entry("segment_bits", sbi->s_proc); remove_proc_entry(sb->s_id, f2fs_proc_root); } kobject_del(&sbi->s_kobj); @@ -745,6 +746,30 @@ static int segment_info_seq_show(struct seq_file *seq, void *offset) return 0; } +static int segment_bits_seq_show(struct seq_file *seq, void *offset) +{ + struct super_block *sb = seq->private; + struct f2fs_sb_info *sbi = F2FS_SB(sb); + unsigned int total_segs = + le32_to_cpu(sbi->raw_super->segment_count_main); + int i, j; + + seq_puts(seq, "format: segment_type|valid_blocks|bitmaps\n" + "segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)\n"); + + for (i = 0; i < total_segs; i++) { + struct seg_entry *se = get_seg_entry(sbi, i); + + seq_printf(seq, "%-10d", i); + seq_printf(seq, "%d|%-3u|", se->type, + get_valid_blocks(sbi, i, 1)); + for (j = 0; j < SIT_VBLOCK_MAP_SIZE; j++) + seq_printf(seq, "%x ", se->cur_valid_map[j]); + seq_putc(seq, '\n'); + } + return 0; +} + #define F2FS_PROC_FILE_DEF(_name) \ static int _name##_open_fs(struct inode *inode, struct file *file) \ { \ @@ -760,6 +785,7 @@ static const struct file_operations f2fs_seq_##_name##_fops = { \ }; F2FS_PROC_FILE_DEF(segment_info); +F2FS_PROC_FILE_DEF(segment_bits); static void default_options(struct f2fs_sb_info *sbi) { @@ -1541,9 +1567,12 @@ try_onemore: if (f2fs_proc_root) sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root); - if (sbi->s_proc) + if (sbi->s_proc) { proc_create_data("segment_info", S_IRUGO, sbi->s_proc, &f2fs_seq_segment_info_fops, sb); + proc_create_data("segment_bits", S_IRUGO, sbi->s_proc, + &f2fs_seq_segment_bits_fops, sb); + } sbi->s_kobj.kset = f2fs_kset; init_completion(&sbi->s_kobj_unregister); @@ -1619,6 +1648,7 @@ free_kobj: free_proc: if (sbi->s_proc) { remove_proc_entry("segment_info", sbi->s_proc); + remove_proc_entry("segment_bits", sbi->s_proc); remove_proc_entry(sb->s_id, f2fs_proc_root); } f2fs_destroy_stats(sbi); |