Skip to contentSkip to conversation

f2fs: add a segment and section num check in sanity_check_raw_super

PATCH New Yunlei He 1 participant 1 message Dec 29, 2015 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH v2 1/1 f2fs: add a segment and section num check in sanity_check_raw_super

This patch add a mismatch check between segment and section in sanity_check_raw_super.

---
 fs/f2fs/super.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/super.c +11 -0
index c3070c1..e88af5a 100644
@@ -1036,6 +1036,17 @@ static int sanity_check_raw_super(struct super_block *sb,
 		return 1;
 	}
 
+	/* check seg # corresponding to sec # */
+	if (le32_to_cpu(raw_super->segment_count_main)
+			/ le32_to_cpu(raw_super->segs_per_sec)
+				!= le32_to_cpu(raw_super->section_count)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch seg num (%u) and sec num (%u) \n",
+			le32_to_cpu(raw_super->segment_count_main),
+			le32_to_cpu(raw_super->section_count));
+		return 1;
+	}
+
 	/* Currently, support 512/1024/2048/4096 bytes sector size */
 	if (le32_to_cpu(raw_super->log_sectorsize) >
 				F2FS_MAX_LOG_SECTOR_SIZE ||
Signature · 4 lines
1.9.1


------------------------------------------------------------------------------