diff mbox series

[f2fs-dev,3/4] fsck.f2fs: add more debug info in fsck_verify()

Message ID 20230512100354.4072489-3-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev,1/4] fsck.f2fs: wrap openned codes into fsck_sanity_check_nid() | expand

Commit Message

Chao Yu May 12, 2023, 10:03 a.m. UTC
In order to track details of stat info and repair flow.

[FSCK] valid_block_count matching with CP             [Fail] [0x2, 0x0]
[FSCK] valid_node_count matching with CP (de lookup)  [Fail] [0x1, 0x0]
[FSCK] valid_node_count matching with CP (nat lookup) [Fail] [0x1, 0x0]
[FSCK] valid_inode_count matched with CP              [Fail] [0x1, 0x0]

Info: flush_journal_entries() n_nats: 1, n_sits: 6
Info: write_checkpoint() cur_cp:1
Info: fix_checkpoint() cur_cp:1

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/fsck.c  | 18 +++++++++++++-----
 fsck/mount.c |  7 ++++++-
 2 files changed, 19 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 9180deb..3650873 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -2407,6 +2407,8 @@  static void fix_checkpoint(struct f2fs_sb_info *sbi)
 
 	ret = f2fs_fsync_device();
 	ASSERT(ret >= 0);
+
+	MSG(0, "Info: fix_checkpoint() cur_cp:%d\n", sbi->cur_cp);
 }
 
 static void fix_checkpoints(struct f2fs_sb_info *sbi)
@@ -3284,7 +3286,8 @@  int fsck_verify(struct f2fs_sb_info *sbi)
 	if (sbi->total_valid_block_count == fsck->chk.valid_blk_cnt) {
 		printf(" [Ok..] [0x%x]\n", (u32)fsck->chk.valid_blk_cnt);
 	} else {
-		printf(" [Fail] [0x%x]\n", (u32)fsck->chk.valid_blk_cnt);
+		printf(" [Fail] [0x%x, 0x%x]\n", sbi->total_valid_block_count,
+					(u32)fsck->chk.valid_blk_cnt);
 		verify_failed = true;
 	}
 
@@ -3292,7 +3295,8 @@  int fsck_verify(struct f2fs_sb_info *sbi)
 	if (sbi->total_valid_node_count == fsck->chk.valid_node_cnt) {
 		printf(" [Ok..] [0x%x]\n", fsck->chk.valid_node_cnt);
 	} else {
-		printf(" [Fail] [0x%x]\n", fsck->chk.valid_node_cnt);
+		printf(" [Fail] [0x%x, 0x%x]\n", sbi->total_valid_node_count,
+						fsck->chk.valid_node_cnt);
 		verify_failed = true;
 	}
 
@@ -3300,7 +3304,8 @@  int fsck_verify(struct f2fs_sb_info *sbi)
 	if (sbi->total_valid_node_count == fsck->chk.valid_nat_entry_cnt) {
 		printf(" [Ok..] [0x%x]\n", fsck->chk.valid_nat_entry_cnt);
 	} else {
-		printf(" [Fail] [0x%x]\n", fsck->chk.valid_nat_entry_cnt);
+		printf(" [Fail] [0x%x, 0x%x]\n", sbi->total_valid_node_count,
+						fsck->chk.valid_nat_entry_cnt);
 		verify_failed = true;
 	}
 
@@ -3308,7 +3313,8 @@  int fsck_verify(struct f2fs_sb_info *sbi)
 	if (sbi->total_valid_inode_count == fsck->chk.valid_inode_cnt) {
 		printf(" [Ok..] [0x%x]\n", fsck->chk.valid_inode_cnt);
 	} else {
-		printf(" [Fail] [0x%x]\n", fsck->chk.valid_inode_cnt);
+		printf(" [Fail] [0x%x, 0x%x]\n", sbi->total_valid_inode_count,
+						fsck->chk.valid_inode_cnt);
 		verify_failed = true;
 	}
 
@@ -3317,7 +3323,9 @@  int fsck_verify(struct f2fs_sb_info *sbi)
 						fsck->chk.sit_free_segs) {
 		printf(" [Ok..] [0x%x]\n", fsck->chk.sit_free_segs);
 	} else {
-		printf(" [Fail] [0x%x]\n", fsck->chk.sit_free_segs);
+		printf(" [Fail] [0x%x, 0x%x]\n",
+			le32_to_cpu(F2FS_CKPT(sbi)->free_segment_count),
+			fsck->chk.sit_free_segs);
 		verify_failed = true;
 	}
 
diff --git a/fsck/mount.c b/fsck/mount.c
index f0b0072..f19f081 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -2782,8 +2782,11 @@  void flush_journal_entries(struct f2fs_sb_info *sbi)
 	int n_nats = flush_nat_journal_entries(sbi);
 	int n_sits = flush_sit_journal_entries(sbi);
 
-	if (n_nats || n_sits)
+	if (n_nats || n_sits) {
+		MSG(0, "Info: flush_journal_entries() n_nats: %d, n_sits: %d\n",
+							n_nats, n_sits);
 		write_checkpoints(sbi);
+	}
 }
 
 void flush_sit_entries(struct f2fs_sb_info *sbi)
@@ -3259,6 +3262,8 @@  void write_checkpoint(struct f2fs_sb_info *sbi)
 
 	ret = f2fs_fsync_device();
 	ASSERT(ret >= 0);
+
+	MSG(0, "Info: write_checkpoint() cur_cp:%d\n", sbi->cur_cp);
 }
 
 void write_checkpoints(struct f2fs_sb_info *sbi)