Skip to contentSkip to conversation

f2fs-tools: use proper address entry count for direct nodes

PATCH Superseded Daeho Jeong 2 participants 5 messages Oct 3, 2023 – Oct 5, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs-tools: use proper address entry count for direct nodes

From: Daeho Jeong <[email protected]>

For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.

---
 fsck/fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/fsck.c +1 -1
index 78ffdb6..56a7d31 100644
@@ -2894,7 +2894,7 @@ 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 < DEF_ADDRS_PER_BLOCK; i++) {
 		addr = le32_to_cpu(node->dn.addr[i]);
 		if (!addr)
 			continue;
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#1 lore raw
Quoted 14 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.

---
 fsck/fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/fsck.c +0 -0
index 78ffdb6..56a7d31 100644

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2897

Quoted 5 lines
fsck/fsck.c +1 -1
@@ -2894,7 +2894,7 @@ 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 < DEF_ADDRS_PER_BLOCK; i++) {

It seems we need to use the inode block passing by fsck_failed_reconnect_file().

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2900

Quoted 3 lines
fsck/fsck.c +0 -0
 		addr = le32_to_cpu(node->dn.addr[i]);
 		if (!addr)
 			continue;

3012 fsck->chk.valid_blk_cnt--;
3013 if (addr == NEW_ADDR)

And, we also need to skip if addr == COMPRESS_ADDR here?

3014 continue;
3015 f2fs_clear_main_bitmap(sbi, addr);
3016 }

Quoted 2 lines
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#2 lore raw
Quoted 19 lines · Jaegeuk Kim
Quoted 17 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.

---
 fsck/fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/fsck.c +0 -0
index 78ffdb6..56a7d31 100644
@@ -2894,7 +2894,7 @@ 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);
 
Quoted 4 lines

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2897

Quoted 2 lines
fsck/fsck.c +1 -1
-     for (i = 0; i < ADDRS_PER_BLOCK(&node->i); i++) {
+     for (i = 0; i < DEF_ADDRS_PER_BLOCK; i++) {

It seems we need to use the inode block passing by fsck_failed_reconnect_file().

This function is for direct nodes. Is it correct to use inode block here?

Quoted 16 lines

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2900

Quoted 4 lines
fsck/fsck.c +0 -0
              addr = le32_to_cpu(node->dn.addr[i]);
              if (!addr)
                      continue;

3012 fsck->chk.valid_blk_cnt--;
3013 if (addr == NEW_ADDR)

And, we also need to skip if addr == COMPRESS_ADDR here?

3014 continue;
3015 f2fs_clear_main_bitmap(sbi, addr);
3016 }

Quoted 2 lines

--
2.42.0.582.g8ccd20d70d-goog

#3 lore raw
Quoted 20 lines · Daeho Jeong
Quoted 19 lines · Jaegeuk Kim
Quoted 17 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.

---
 fsck/fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/fsck.c +0 -0
index 78ffdb6..56a7d31 100644
@@ -2894,7 +2894,7 @@ 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);
 
Quoted 6 lines
Quoted 4 lines

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2897

Quoted 2 lines
fsck/fsck.c +1 -1
-     for (i = 0; i < ADDRS_PER_BLOCK(&node->i); i++) {
+     for (i = 0; i < DEF_ADDRS_PER_BLOCK; i++) {

It seems we need to use the inode block passing by fsck_failed_reconnect_file().

This function is for direct nodes. Is it correct to use inode block here?

523 unsigned int addrs_per_block(struct f2fs_inode *i) 524 {
525 if (!LINUX_S_ISREG(le16_to_cpu(i->i_mode)) ||
526 !(le32_to_cpu(i->i_flags) & F2FS_COMPR_FL))
527 return DEF_ADDRS_PER_BLOCK;
528 return ALIGN_DOWN(DEF_ADDRS_PER_BLOCK, 1 << i->i_log_cluster_size);
529 }

If the inode is compressed, it seems it has to be aligned to cluster size.

Quoted 17 lines
Quoted 17 lines

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2900

Quoted 5 lines
fsck/fsck.c +0 -0
              addr = le32_to_cpu(node->dn.addr[i]);
              if (!addr)
                      continue;

3012 fsck->chk.valid_blk_cnt--;
3013 if (addr == NEW_ADDR)

And, we also need to skip if addr == COMPRESS_ADDR here?

3014 continue;
3015 f2fs_clear_main_bitmap(sbi, addr);
3016 }

Quoted 2 lines

--
2.42.0.582.g8ccd20d70d-goog

#4 lore raw
Quoted 37 lines · Jaegeuk Kim
Quoted 20 lines · Daeho Jeong
Quoted 19 lines · Jaegeuk Kim
Quoted 17 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.

---
 fsck/fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/fsck.c +0 -0
index 78ffdb6..56a7d31 100644
@@ -2894,7 +2894,7 @@ 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);
 
Quoted 6 lines
Quoted 4 lines

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2897

Quoted 2 lines
fsck/fsck.c +1 -1
-     for (i = 0; i < ADDRS_PER_BLOCK(&node->i); i++) {
+     for (i = 0; i < DEF_ADDRS_PER_BLOCK; i++) {

It seems we need to use the inode block passing by fsck_failed_reconnect_file().

This function is for direct nodes. Is it correct to use inode block here?

523 unsigned int addrs_per_block(struct f2fs_inode *i) 524 {
525 if (!LINUX_S_ISREG(le16_to_cpu(i->i_mode)) ||
526 !(le32_to_cpu(i->i_flags) & F2FS_COMPR_FL))
527 return DEF_ADDRS_PER_BLOCK;
528 return ALIGN_DOWN(DEF_ADDRS_PER_BLOCK, 1 << i->i_log_cluster_size);
529 }

Quoted 1 line

If the inode is compressed, it seems it has to be aligned to cluster size.

makes sense. Thanks~!

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

fsck/fsck.c static void fsck_failed_reconnect_file_dnode(struct f2fs_sb_info *sbi, · line 2900

Quoted 6 lines
fsck/fsck.c +0 -0
              addr = le32_to_cpu(node->dn.addr[i]);
              if (!addr)
                      continue;

3012 fsck->chk.valid_blk_cnt--;
3013 if (addr == NEW_ADDR)

And, we also need to skip if addr == COMPRESS_ADDR here?

3014 continue;
3015 f2fs_clear_main_bitmap(sbi, addr);
3016 }

Quoted 2 lines

--
2.42.0.582.g8ccd20d70d-goog