f2fs: fix to check ckpt blocks of section in get_victim_by_default()
PATCH 1/1 f2fs: fix to check ckpt blocks of section in get_victim_by_default()
In image which enables large section, if we disable checkpoint, during background GC, it needs to check whether there is checkpointed data in selected victim section, rather than segment, fix this.
Fixes 4354994f097d ("f2fs: checkpoint disabling")
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/gc.c | 4 ++-- fs/f2fs/segment.c | 18 ++++-------------- fs/f2fs/segment.h | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 17 deletions(-)
fs/f2fs/gc.c +2 -2
@@ -726,8 +726,8 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, goto next;/* Don't touch checkpointed data */ if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ) && -get_ckpt_valid_blocks (sbi, segno) && - p.alloc_mode ==LFS )) +get_ckpt_valid_blocks (sbi, segno, true) && + p.alloc_mode ==LFS )) goto next;if (gc_type ==BG_GC &&test_bit (secno, dirty_i->victim_secmap)) goto next;
fs/f2fs/segment.c +4 -14
@@ -865,7 +865,7 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)mutex_lock (&dirty_i->seglist_lock); valid_blocks =get_valid_blocks (sbi, segno, false); - ckpt_valid_blocks =get_ckpt_valid_blocks (sbi, segno); + ckpt_valid_blocks =get_ckpt_valid_blocks (sbi, segno, false);if (valid_blocks ==0 && (!is_sbi_flag_set (sbi,SBI_CP_DISABLED ) || ckpt_valid_blocks == usable_blocks)) {
@@ -950,7 +950,7 @@ static unsigned int get_free_segment(struct f2fs_sb_info *sbi)for_each_set_bit (segno, dirty_i->dirty_segmap[DIRTY ],MAIN_SEGS (sbi)) {if (get_valid_blocks (sbi, segno, false))continue ; -if (get_ckpt_valid_blocks (sbi, segno)) +if (get_ckpt_valid_blocks (sbi, segno, false))continue ;mutex_unlock (&dirty_i->seglist_lock);return segno;
@@ -2933,18 +2933,8 @@ static void __allocate_new_segment(struct f2fs_sb_info *sbi, int type, get_valid_blocks(sbi, curseg->segno, new_sec)) goto alloc; -if (new_sec) { -unsigned int segno =START_SEGNO (curseg->segno); -int i; - -for (i =0 ; i < sbi->segs_per_sec; i++, segno++) { -if (get_ckpt_valid_blocks (sbi, segno)) - goto alloc; - } - }else { -if (!get_ckpt_valid_blocks (sbi, curseg->segno)) -return ; - } +if (!get_ckpt_valid_blocks (sbi, curseg->segno, new_sec)) +return ; alloc: old_segno = curseg->segno;
fs/f2fs/segment.h +14 -1
@@ -359,8 +359,21 @@ static inline unsigned int get_valid_blocks(struct f2fs_sb_info *sbi, }static inline unsigned int get_ckpt_valid_blocks (struct f2fs_sb_info *sbi, -unsigned int segno) +unsigned int segno,bool use_section) { +if (use_section &&__is_large_section (sbi)) { +unsigned int start_segno =START_SEGNO (segno); +unsigned int blocks =0 ; +int i; + +for (i =0 ; i < sbi->segs_per_sec; i++, start_segno++) { +struct seg_entry *se =get_seg_entry (sbi, start_segno); + + blocks += se->ckpt_valid_blocks; + } +return blocks; + } +return get_seg_entry (sbi, segno)->ckpt_valid_blocks; }
Signature · 1 line
2.29.2