Skip to contentSkip to conversation

f2fs-tools: fix the calculation for raw_node->footer.next_blkaddr in f2fs_write_root_inode

PATCH In review Wang Sheng-Hui 2 participants 3 messages Jun 28, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 f2fs-tools: fix the calculation for raw_node->footer.next_blkaddr in f2fs_write_root_inode

The raw_node will take 1 blk itself, and its next blk addr should be +1.

---
  mkfs/f2fs_format.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mkfs/f2fs_format.c +1 -1
index 06771ff..f00ba04 100644
@@ -744,7 +744,7 @@ static int f2fs_write_root_inode(void)
  	raw_node->footer.next_blkaddr = cpu_to_le32(
  			le32_to_cpu(super_block.main_blkaddr) +
  			config.cur_seg[CURSEG_HOT_NODE] *
-			config.blks_per_seg + 1);
+			config.blks_per_seg) + cpu_to_le32(1);
 
  	raw_node->i.i_mode = cpu_to_le16(0x41ed);
  	raw_node->i.i_links = cpu_to_le32(2);
Signature · 8 lines
1.7.10.4

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
#1 lore raw

Hi,

Again, it doesn't make sense why we should cpu_to_le32(x) + cpu_to_le32(1) instead of cpu_to_le32(x + 1).

What is the problem?

2013-06-28 (금), 13:12 +0800, Wang Sheng-Hui:

Quoted 20 lines

The raw_node will take 1 blk itself, and its next blk addr should be +1.

---
  mkfs/f2fs_format.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mkfs/f2fs_format.c +1 -1
index 06771ff..f00ba04 100644
@@ -744,7 +744,7 @@ static int f2fs_write_root_inode(void)
  	raw_node->footer.next_blkaddr = cpu_to_le32(
  			le32_to_cpu(super_block.main_blkaddr) +
  			config.cur_seg[CURSEG_HOT_NODE] *
-			config.blks_per_seg + 1);
+			config.blks_per_seg) + cpu_to_le32(1);
 
  	raw_node->i.i_mode = cpu_to_le16(0x41ed);
  	raw_node->i.i_links = cpu_to_le32(2);
Signature · 14 lines
Jaegeuk Kim
Samsung


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#2 lore raw
In reply to Wang Sheng-Hui
Quoted 12 lines · Wang Sheng-Hui

The raw_node will take 1 blk itself, and its next blk addr should be +1.

---
  mkfs/f2fs_format.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mkfs/f2fs_format.c +0 -0
index 06771ff..f00ba04 100644

mkfs/f2fs_format.c static int f2fs_write_root_inode(void) · line 750

Quoted 8 lines
mkfs/f2fs_format.c +1 -1
@@ -744,7 +744,7 @@ static int f2fs_write_root_inode(void)
      raw_node->footer.next_blkaddr = cpu_to_le32(
              le32_to_cpu(super_block.main_blkaddr) +
              config.cur_seg[CURSEG_HOT_NODE] *
-            config.blks_per_seg + 1);
+            config.blks_per_seg) + cpu_to_le32(1);
 
      raw_node->i.i_mode = cpu_to_le16(0x41ed);
      raw_node->i.i_links = cpu_to_le32(2);

Sorry, I mislooked the () position. And the origin calculation is right. Please ignore this patch.

Thanks,
Sheng-Hui

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel