diff mbox series

[f2fs-dev,v2] f2fs-tools: use proper address entry count for direct nodes

Message ID 20231009202917.1835899-1-daeho43@gmail.com (mailing list archive)
State New
Headers show
Series [f2fs-dev,v2] f2fs-tools: use proper address entry count for direct nodes | expand

Commit Message

Daeho Jeong Oct. 9, 2023, 8:29 p.m. UTC
From: Daeho Jeong <daehojeong@google.com>

For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
v2: pass inode struct as a parameter and check COMPRESS_ADDR
---
 fsck/fsck.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Chao Yu Oct. 10, 2023, 1:33 a.m. UTC | #1
On 2023/10/10 4:29, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.
> 
> Signed-off-by: Daeho Jeong <daehojeong@google.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
diff mbox series

Patch

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 78ffdb6..3ade728 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -2875,7 +2875,7 @@  static int fsck_do_reconnect_file(struct f2fs_sb_info *sbi,
 }
 
 static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi,
-					     nid_t nid)
+					struct f2fs_inode *inode, nid_t nid)
 {
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
 	struct f2fs_node *node;
@@ -2894,12 +2894,12 @@  static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi,
 	fsck->chk.valid_blk_cnt--;
 	f2fs_clear_main_bitmap(sbi, ni.blk_addr);
 
-	for (i = 0; i < ADDRS_PER_BLOCK(&node->i); i++) {
+	for (i = 0; i < ADDRS_PER_BLOCK(inode); i++) {
 		addr = le32_to_cpu(node->dn.addr[i]);
 		if (!addr)
 			continue;
 		fsck->chk.valid_blk_cnt--;
-		if (addr == NEW_ADDR)
+		if (addr == NEW_ADDR || addr == COMPRESS_ADDR)
 			continue;
 		f2fs_clear_main_bitmap(sbi, addr);
 	}
@@ -2908,7 +2908,7 @@  static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi,
 }
 
 static void fsck_failed_reconnect_file_idnode(struct f2fs_sb_info *sbi,
-					      nid_t nid)
+					struct f2fs_inode *inode, nid_t nid)
 {
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
 	struct f2fs_node *node;
@@ -2931,14 +2931,14 @@  static void fsck_failed_reconnect_file_idnode(struct f2fs_sb_info *sbi,
 		tmp = le32_to_cpu(node->in.nid[i]);
 		if (!tmp)
 			continue;
-		fsck_failed_reconnect_file_dnode(sbi, tmp);
+		fsck_failed_reconnect_file_dnode(sbi, inode, tmp);
 	}
 
 	free(node);
 }
 
 static void fsck_failed_reconnect_file_didnode(struct f2fs_sb_info *sbi,
-					       nid_t nid)
+					struct f2fs_inode *inode, nid_t nid)
 {
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
 	struct f2fs_node *node;
@@ -2961,7 +2961,7 @@  static void fsck_failed_reconnect_file_didnode(struct f2fs_sb_info *sbi,
 		tmp = le32_to_cpu(node->in.nid[i]);
 		if (!tmp)
 			continue;
-		fsck_failed_reconnect_file_idnode(sbi, tmp);
+		fsck_failed_reconnect_file_idnode(sbi, inode, tmp);
 	}
 
 	free(node);
@@ -3010,7 +3010,7 @@  static void fsck_failed_reconnect_file(struct f2fs_sb_info *sbi, nid_t ino)
 			if (!addr)
 				continue;
 			fsck->chk.valid_blk_cnt--;
-			if (addr == NEW_ADDR)
+			if (addr == NEW_ADDR || addr == COMPRESS_ADDR)
 				continue;
 			f2fs_clear_main_bitmap(sbi, addr);
 		}
@@ -3024,14 +3024,14 @@  static void fsck_failed_reconnect_file(struct f2fs_sb_info *sbi, nid_t ino)
 		switch (i) {
 		case 0: /* direct node */
 		case 1:
-			fsck_failed_reconnect_file_dnode(sbi, nid);
+			fsck_failed_reconnect_file_dnode(sbi, &node->i, nid);
 			break;
 		case 2: /* indirect node */
 		case 3:
-			fsck_failed_reconnect_file_idnode(sbi, nid);
+			fsck_failed_reconnect_file_idnode(sbi, &node->i, nid);
 			break;
 		case 4: /* double indirect node */
-			fsck_failed_reconnect_file_didnode(sbi, nid);
+			fsck_failed_reconnect_file_didnode(sbi, &node->i, nid);
 			break;
 		}
 	}