f2fs: check total_segments from devices in raw_super
Subsystems (2)
PATCH 1/1 f2fs: check total_segments from devices in raw_super
From: Qiuyang Sun <[email protected]>
For multi-device F2FS, we should check if the sum of total_segments from all devices matches segment_count.
Signed-off-by Qiuyang Sun <[email protected]>
--- fs/f2fs/super.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/f2fs/super.c +15 -0
@@ -2602,6 +2602,21 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EFSCORRUPTED ; } +if (RDEV (0 ).path[0 ]) { +block_t dev_seg_count =le32_to_cpu (RDEV (0 ).total_segments); +int i =1 ; + +while (i <MAX_DEVICES &&RDEV (i).path[0 ]) { + dev_seg_count +=le32_to_cpu (RDEV (i).total_segments); + i++; + } +if (segment_count != dev_seg_count) { +f2fs_info (sbi,"Segment count (%u) mismatch with total segments from devices (%u)" , + segment_count, dev_seg_count); +return -EFSCORRUPTED ; + } + } +if (secs_per_zone > total_sections || !secs_per_zone) {f2fs_info (sbi,"Wrong secs_per_zone / total_sections (%u, %u)" , secs_per_zone, total_sections);
Signature · 1 line
1.8.3.1
Quoted 6 lines · sunqiuyang
From: Qiuyang Sun <[email protected]>
For multi-device F2FS, we should check if the sum of
total_segmentsfrom all devices matchessegment_count.Signed-off-by Qiuyang Sun <[email protected]>
Reviewed-by Chao Yu <[email protected]>
Thanks,