Skip to contentSkip to conversation

f2fs-tools: calculate cp_ver correctly

PATCH New Chao Yu 1 participant 1 message Mar 2, 2017

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs-tools: calculate cp_ver correctly

It needs to check CP_CRC_RECOVERY_FLAG during cp_ver calculation.

---
 include/f2fs_fs.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/f2fs_fs.h +4 -1
index 057adf39f6a9..a92011b83ff5 100644
@@ -1089,10 +1089,13 @@ static inline __le64 get_cp_crc(struct f2fs_checkpoint *cp)
 {
 	u_int64_t cp_ver = get_cp(checkpoint_ver);
 	size_t crc_offset = get_cp(checksum_offset);
+	unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
+
 	u_int32_t crc = le32_to_cpu(*(__le32 *)((unsigned char *)cp +
 							crc_offset));
 
-	cp_ver |= ((u_int64_t)crc << 32);
+	if (ckpt_flags & CP_CRC_RECOVERY_FLAG)
+		cp_ver |= ((u_int64_t)crc << 32);
 	return cpu_to_le64(cp_ver);
 }
 
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