diff options
author | Chao Yu <yuchao0@huawei.com> | 2019-08-09 18:52:59 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2019-08-27 14:51:05 -0700 |
commit | 207e2d7a03d9f158d881d32bdc9fc103209663cd (patch) | |
tree | 71a5618f2b34c4e3415016a20735737658711047 | |
parent | a624d790f202ba8a208ef221d638d76df4a49895 (diff) | |
download | f2fs-tools-207e2d7a03d9f158d881d32bdc9fc103209663cd.tar.gz |
fsck.f2fs: fix to set large section type during allocation
During block allocation in large free section, we need to change
all sub segments' type in it, otherwise, we will fail to allocate
block in non-first segment due to mismatch seg-type.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/mount.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/fsck/mount.c b/fsck/mount.c index ba0fa99..93e6fa2 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -2396,6 +2396,20 @@ int relocate_curseg_offset(struct f2fs_sb_info *sbi, int type) return 0; } +void set_section_type(struct f2fs_sb_info *sbi, unsigned int segno, int type) +{ + struct seg_entry *se; + unsigned int i; + + if (sbi->segs_per_sec == 1) + return; + + for (i = 0; i < sbi->segs_per_sec; i++) { + se = get_seg_entry(sbi, segno + i); + se->type = type; + } +} + int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) { struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); @@ -2439,8 +2453,11 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) if (se2->valid_blocks) break; } - if (i == sbi->segs_per_sec) + + if (i == sbi->segs_per_sec) { + set_section_type(sbi, segno, type); return 0; + } } if (se->type == type && |