resize.f2fs (f2fs_defragment) tries to migrate blocks to new positions. However, if a curseg is selected, and f2fs_defragment is broken by any error, curseg->next_blkoff is left not updated.
To avoid this, we skip cursegs when finding next free block. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/f2fs.h | 5 +---- fsck/fsck.c | 2 +- fsck/mount.c | 8 +++----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/fsck/f2fs.h b/fsck/f2fs.h index d0e08aa..d216444 100644 --- a/fsck/f2fs.h +++ b/fsck/f2fs.h @@ -380,16 +380,13 @@ static inline bool IS_VALID_BLK_ADDR(struct f2fs_sb_info *sbi, u32 addr) return 1; } -static inline int IS_CUR_SEGNO(struct f2fs_sb_info *sbi, u32 segno, int type) +static inline int IS_CUR_SEGNO(struct f2fs_sb_info *sbi, u32 segno) { int i; for (i = 0; i < NO_CHECK_TYPE; i++) { struct curseg_info *curseg = CURSEG_I(sbi, i); - if (type == i) - continue; - if (segno == curseg->segno) return 1; } diff --git a/fsck/fsck.c b/fsck/fsck.c index 5b6dbc8..8145199 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -1741,7 +1741,7 @@ int fsck_chk_meta(struct f2fs_sb_info *sbi) se = get_seg_entry(sbi, i); if (se->valid_blocks != 0) sit_valid_segs++; - else if (IS_CUR_SEGNO(sbi, i, NO_CHECK_TYPE)) { + else if (IS_CUR_SEGNO(sbi, i)) { /* curseg has not been written back to device */ MSG(1, "\tInfo: curseg %u is counted in valid segs\n", i); sit_valid_segs++; diff --git a/fsck/mount.c b/fsck/mount.c index 0a30adb..8d4704e 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -35,8 +35,7 @@ u32 get_free_segments(struct f2fs_sb_info *sbi) for (i = 0; i < TOTAL_SEGS(sbi); i++) { struct seg_entry *se = get_seg_entry(sbi, i); - if (se->valid_blocks == 0x0 && - !IS_CUR_SEGNO(sbi, i, NO_CHECK_TYPE)) + if (se->valid_blocks == 0x0 && !IS_CUR_SEGNO(sbi, i)) free_segs++; } return free_segs; @@ -1891,8 +1890,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi) se->valid_blocks); rewrite_current_sit_page(sbi, segno, sit_blk); - if (se->valid_blocks == 0x0 && - !IS_CUR_SEGNO(sbi, segno, NO_CHECK_TYPE)) + if (se->valid_blocks == 0x0 && !IS_CUR_SEGNO(sbi, segno)) free_segs++; } @@ -1922,7 +1920,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) se = get_seg_entry(sbi, segno); if (se->valid_blocks == sbi->blocks_per_seg || - IS_CUR_SEGNO(sbi, segno, type)) { + IS_CUR_SEGNO(sbi, segno)) { *to = left ? START_BLOCK(sbi, segno) - 1: START_BLOCK(sbi, segno + 1); continue; -- 2.17.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel