summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorQiuyang Sun <sunqiuyang@huawei.com>2019-09-23 12:22:35 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2019-10-22 10:32:42 -0700
commit9f701f6c772b15461843b92f9b41a0705e190a86 (patch)
tree9b269f39919d22348f0351ac054d2617bc9f6147 /fs/f2fs
parent46d9ce195a2b1b8aceeafae1d8f407383a117b0e (diff)
downloadlinux-9f701f6c772b15461843b92f9b41a0705e190a86.tar.bz2
f2fs: check total_segments from devices in raw_super
For multi-device F2FS, we should check if the sum of total_segments from all devices matches segment_count. Signed-off-by: Qiuyang Sun <sunqiuyang@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/super.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f3a68af3b43a..112eb86a120f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2604,6 +2604,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);