Skip to contentSkip to conversation

f2fs: correct cp_ver for compatibility to old image

PATCH In review Chao Yu 2 participants 3 messages Mar 2, 2017 – Mar 6, 2017 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs: correct cp_ver for compatibility to old image

There is no CP_CRC_RECOVERY_FLAG tagged in checkpoint pack, calculate cp_version as old format.

---
 fs/f2fs/node.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/node.c +3 -1
index 6c027b6833f4..0d46404ca769 100644
@@ -2507,7 +2507,9 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
 		f2fs_put_page(page, 1);
 	}
 
-	cp_ver |= (cur_cp_crc(ckpt) << 32);
+	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
+		cp_ver |= (cur_cp_crc(ckpt) << 32);
+
 	if (cpu_to_le64(cp_ver) != *(__le64 *)nm_i->nat_bits) {
 		disable_nat_bits(sbi, true);
 		return 0;
Signature · 6 lines
2.8.2.295.g3f1c1d0


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

There is no CP_CRC_RECOVERY_FLAG tagged in checkpoint pack, calculate cp_version as old format.

---
 fs/f2fs/node.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/node.c +0 -0
index 6c027b6833f4..0d46404ca769 100644

fs/f2fs/node.c static int __get_nat_bitmaps(struct f2fs_sb_info *sbi) · line 2511

Quoted 6 lines
fs/f2fs/node.c +2 -1
@@ -2507,7 +2507,9 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
 		f2fs_put_page(page, 1);
 	}
 
-	cp_ver |= (cur_cp_crc(ckpt) << 32);
+	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
+		cp_ver |= (cur_cp_crc(ckpt) << 32);

Well, we always write nat_bits with crc. So if it's different, something is wrong and we need to drop it. CP-CRC_RECOVERY_FLAG is used for roll-forward recovery, which is a different context.

Quoted 6 lines
fs/f2fs/node.c +1 -0
+
 	if (cpu_to_le64(cp_ver) != *(__le64 *)nm_i->nat_bits) {
 		disable_nat_bits(sbi, true);
 		return 0;
Signature · 1 line
2.8.2.295.g3f1c1d0

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

author
#2 lore raw
Quoted 17 lines · Jaegeuk Kim
Quoted 16 lines · Chao Yu

There is no CP_CRC_RECOVERY_FLAG tagged in checkpoint pack, calculate cp_version as old format.

---
 fs/f2fs/node.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/node.c +0 -0
index 6c027b6833f4..0d46404ca769 100644
@@ -2507,7 +2507,9 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
 		f2fs_put_page(page, 1);
 	}
 
Quoted 6 lines

fs/f2fs/node.c static int __get_nat_bitmaps(struct f2fs_sb_info *sbi) · line 2511

Quoted 3 lines
fs/f2fs/node.c +2 -1
-	cp_ver |= (cur_cp_crc(ckpt) << 32);
+	if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
+		cp_ver |= (cur_cp_crc(ckpt) << 32);

Well, we always write nat_bits with crc. So if it's different, something is wrong and we need to drop it.

Got it. :)

Thanks,

Quoted 11 lines

CP-CRC_RECOVERY_FLAG is used for roll-forward recovery, which is a different context.

Quoted 6 lines
fs/f2fs/node.c +1 -0
+
 	if (cpu_to_le64(cp_ver) != *(__le64 *)nm_i->nat_bits) {
 		disable_nat_bits(sbi, true);
 		return 0;
Signature · 1 line
2.8.2.295.g3f1c1d0

.

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