Skip to contentSkip to conversation

fsck.f2fs: check total_segments from devices in raw_super

PATCH Chao Yu 1 participant 1 message Sep 23, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Chao Yu

author Reviewed-by
#1 lore raw

+Cc f2fs mailing list

Quoted 6 lines · sunqiuyang

From: Qiuyang Sun <[email protected]>

For multi-device F2FS, we should check if the sum of total_segments from all devices matches segment_count.

Thanks,

Quoted 21 lines
---
 fsck/mount.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
fsck/mount.c +8 -0
index 4814dfe..7d268e3 100644
@@ -782,6 +782,21 @@ int sanity_check_raw_super(struct f2fs_super_block *sb, enum SB_ADDR sb_addr)
 		return 1;
 	}
 
+	if (sb->devs[0].path[0]) {
+		unsigned int dev_segs = le32_to_cpu(sb->devs[0].total_segments);
+		int i = 1;
+
+		while (i < MAX_DEVICES && sb->devs[i].path[0]) {
+			dev_segs += le32_to_cpu(sb->devs[i].total_segments);
+			i++;
+		}

fsck/mount.c int sanity_check_raw_super(struct f2fs_super_block *sb, enum SB_ADDR sb_addr) · line 802

Quoted 10 lines
fsck/mount.c +7 -0
+		if (segment_count != dev_segs) {
+			MSG(0, "Segment count (%u) mismatch with total segments from devices (%u)",
+				segment_count, dev_segs);
+			return 1;
+		}
+	}
+
 	if (secs_per_zone > total_sections || !secs_per_zone) {
 		MSG(0, "Wrong secs_per_zone / total_sections (%u, %u)\n",
 			secs_per_zone, total_sections);

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel