diff options
author | Qiuyang Sun <sunqiuyang@huawei.com> | 2019-09-23 12:24:59 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2019-12-09 17:23:19 -0800 |
commit | 05fee40110881bab81de649bdb8462dfbdd19220 (patch) | |
tree | d0c06196140224832b2413b787e4888257fc0374 | |
parent | 51e7d6dee33b1117875cc6628216af7b4aeba6ab (diff) | |
download | f2fs-tools-05fee40110881bab81de649bdb8462dfbdd19220.tar.gz |
fsck.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>
-rw-r--r-- | fsck/mount.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fsck/mount.c b/fsck/mount.c index 4814dfe..7d268e3 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -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++; + } + 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); |