Skip to content

Commit f238eff

Browse files
author
Jaegeuk Kim
committed
f2fs: add a proc entry show disk layout
This patch adds the disk map of block address ranges configured by multiple partitions. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 45809cd commit f238eff

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

fs/f2fs/sysfs.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,50 @@ static int __maybe_unused discard_plist_seq_show(struct seq_file *seq,
14921492
return 0;
14931493
}
14941494

1495+
static int __maybe_unused disk_map_seq_show(struct seq_file *seq,
1496+
void *offset)
1497+
{
1498+
struct super_block *sb = seq->private;
1499+
struct f2fs_sb_info *sbi = F2FS_SB(sb);
1500+
int i;
1501+
1502+
seq_printf(seq, "Address Layout : %5luB Block address (# of Segments)\n",
1503+
F2FS_BLKSIZE);
1504+
seq_printf(seq, " SB : %12s\n", "0/1024B");
1505+
seq_printf(seq, " seg0_blkaddr : 0x%010x\n", SEG0_BLKADDR(sbi));
1506+
seq_printf(seq, " Checkpoint : 0x%010x (%10d)\n",
1507+
le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_blkaddr), 2);
1508+
seq_printf(seq, " SIT : 0x%010x (%10d)\n",
1509+
SIT_I(sbi)->sit_base_addr,
1510+
le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_sit));
1511+
seq_printf(seq, " NAT : 0x%010x (%10d)\n",
1512+
NM_I(sbi)->nat_blkaddr,
1513+
le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_nat));
1514+
seq_printf(seq, " SSA : 0x%010x (%10d)\n",
1515+
SM_I(sbi)->ssa_blkaddr,
1516+
le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_ssa));
1517+
seq_printf(seq, " Main : 0x%010x (%10d)\n",
1518+
SM_I(sbi)->main_blkaddr,
1519+
le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_main));
1520+
seq_printf(seq, " # of Sections : %12d\n",
1521+
le32_to_cpu(F2FS_RAW_SUPER(sbi)->section_count));
1522+
seq_printf(seq, " Segs/Sections : %12d\n",
1523+
SEGS_PER_SEC(sbi));
1524+
seq_printf(seq, " Section size : %12d MB\n",
1525+
SEGS_PER_SEC(sbi) << 1);
1526+
1527+
if (!f2fs_is_multi_device(sbi))
1528+
return 0;
1529+
1530+
seq_puts(seq, "\nDisk Map for multi devices:\n");
1531+
for (i = 0; i < sbi->s_ndevs; i++)
1532+
seq_printf(seq, "Disk:%2d (zoned=%d): 0x%010x - 0x%010x on %s\n",
1533+
i, bdev_is_zoned(FDEV(i).bdev),
1534+
FDEV(i).start_blk, FDEV(i).end_blk,
1535+
FDEV(i).path);
1536+
return 0;
1537+
}
1538+
14951539
int __init f2fs_init_sysfs(void)
14961540
{
14971541
int ret;
@@ -1573,6 +1617,8 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
15731617
victim_bits_seq_show, sb);
15741618
proc_create_single_data("discard_plist_info", 0444, sbi->s_proc,
15751619
discard_plist_seq_show, sb);
1620+
proc_create_single_data("disk_map", 0444, sbi->s_proc,
1621+
disk_map_seq_show, sb);
15761622
return 0;
15771623
put_feature_list_kobj:
15781624
kobject_put(&sbi->s_feature_list_kobj);

0 commit comments

Comments
 (0)