Skip to contentSkip to conversation

mkfs.f2fs: make sure clean all reset dnodes

PATCH In review Kinglong Mee 2 participants 2 messages Feb 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.f2fs: make sure clean all reset dnodes

memset(raw_node, 0, F2FS_BLKSIZE) sets the next_blkaddr to zero, so that, only one reset dnode is cleaned always.

Fixes ad042d9194f5 "mkfs.f2fs: reset dnode with zeros",
---
 mkfs/f2fs_format.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +4 -1
index 3c13026..1b10e4f 100644
@@ -775,6 +775,8 @@ static int f2fs_write_super_block(void)
 #ifndef WITH_ANDROID
 static int discard_obsolete_dnode(struct f2fs_node *raw_node, u_int64_t offset)
 {
+	u_int64_t next_blkaddr = 0;
+
 	if (c.zoned_mode)
 		return 0;
 	do {
@@ -787,6 +789,7 @@ static int discard_obsolete_dnode(struct f2fs_node *raw_node, u_int64_t offset)
 			return -1;
 		}
 
+		next_blkaddr = le32_to_cpu(raw_node->footer.next_blkaddr);
 		memset(raw_node, 0, F2FS_BLKSIZE);
 
 		DBG(1, "\tDiscard dnode, at offset 0x%08"PRIx64"\n", offset);
@@ -794,7 +797,7 @@ static int discard_obsolete_dnode(struct f2fs_node *raw_node, u_int64_t offset)
 			MSG(1, "\tError: While discarding direct node!!!\n");
 			return -1;
 		}
-		offset = le32_to_cpu(raw_node->footer.next_blkaddr);
+		offset = next_blkaddr;
 	} while (1);
 
 	return 0;
Signature · 6 lines
2.9.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
#1 lore raw

Nice catch!

Quoted 41 lines · Kinglong Mee

memset(raw_node, 0, F2FS_BLKSIZE) sets the next_blkaddr to zero, so that, only one reset dnode is cleaned always.

Fixes ad042d9194f5 "mkfs.f2fs: reset dnode with zeros",
---
 mkfs/f2fs_format.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +4 -1
index 3c13026..1b10e4f 100644
@@ -775,6 +775,8 @@ static int f2fs_write_super_block(void)
 #ifndef WITH_ANDROID
 static int discard_obsolete_dnode(struct f2fs_node *raw_node, u_int64_t offset)
 {
+	u_int64_t next_blkaddr = 0;
+
 	if (c.zoned_mode)
 		return 0;
 	do {
@@ -787,6 +789,7 @@ static int discard_obsolete_dnode(struct f2fs_node *raw_node, u_int64_t offset)
 			return -1;
 		}
 
+		next_blkaddr = le32_to_cpu(raw_node->footer.next_blkaddr);
 		memset(raw_node, 0, F2FS_BLKSIZE);
 
 		DBG(1, "\tDiscard dnode, at offset 0x%08"PRIx64"\n", offset);
@@ -794,7 +797,7 @@ static int discard_obsolete_dnode(struct f2fs_node *raw_node, u_int64_t offset)
 			MSG(1, "\tError: While discarding direct node!!!\n");
 			return -1;
 		}
-		offset = le32_to_cpu(raw_node->footer.next_blkaddr);
+		offset = next_blkaddr;
 	} while (1);
 
 	return 0;
Signature · 1 line
2.9.3

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot