Skip to contentSkip to conversation

fsck.f2fs: write back last cp block in the end

PATCH In review Yunlei He 2 participants 2 messages Aug 23, 2017 – Aug 24, 2017

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 fsck.f2fs: write back last cp block in the end

Write back last cp block in the end in case of sudden power off during fsck process

---
 fsck/mount.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
fsck/mount.c +7 -4
index a0b0bea..700a4ff 100644
@@ -1918,13 +1918,16 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
 		ASSERT(ret >= 0);
 	}
 
-	/* write the last cp */
-	ret = dev_write_block(cp, cp_blk_no++);
-	ASSERT(ret >= 0);
-
 	/* Write nat bits */
 	if (flags & CP_NAT_BITS_FLAG)
 		write_nat_bits(sbi, sb, cp, sbi->cur_cp);
+
+	/* in case of sudden power off */
+	f2fs_finalize_device();
+
+	/* write the last cp */
+	ret = dev_write_block(cp, cp_blk_no++);
+	ASSERT(ret >= 0);
 }
 
 void build_nat_area_bitmap(struct f2fs_sb_info *sbi)
Signature · 6 lines
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Yunlei He

Write back last cp block in the end in case of sudden power off during fsck process

Quoted 20 lines
---
 fsck/mount.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
fsck/mount.c +0 -4
index a0b0bea..700a4ff 100644
@@ -1918,13 +1918,16 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
 		ASSERT(ret >= 0);
 	}
 
-	/* write the last cp */
-	ret = dev_write_block(cp, cp_blk_no++);
-	ASSERT(ret >= 0);
-
 	/* Write nat bits */
 	if (flags & CP_NAT_BITS_FLAG)
 		write_nat_bits(sbi, sb, cp, sbi->cur_cp);

fsck/mount.c void write_checkpoint(struct f2fs_sb_info *sbi) · line 1933

Quoted 10 lines
fsck/mount.c +7 -0
+
+	/* in case of sudden power off */
+	f2fs_finalize_device();
+
+	/* write the last cp */
+	ret = dev_write_block(cp, cp_blk_no++);
+	ASSERT(ret >= 0);
 }
 
 void build_nat_area_bitmap(struct f2fs_sb_info *sbi)

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