|
@@ -166,7 +166,8 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
|
|
|
p->ofs_unit = sbi->segs_per_sec;
|
|
|
}
|
|
|
|
|
|
- if (p->max_search > sbi->max_victim_search)
|
|
|
+ /* we need to check every dirty segments in the FG_GC case */
|
|
|
+ if (gc_type != FG_GC && p->max_search > sbi->max_victim_search)
|
|
|
p->max_search = sbi->max_victim_search;
|
|
|
|
|
|
p->offset = sbi->last_victim[p->gc_mode];
|
|
@@ -199,6 +200,10 @@ static unsigned int check_bg_victims(struct f2fs_sb_info *sbi)
|
|
|
for_each_set_bit(secno, dirty_i->victim_secmap, MAIN_SECS(sbi)) {
|
|
|
if (sec_usage_check(sbi, secno))
|
|
|
continue;
|
|
|
+
|
|
|
+ if (no_fggc_candidate(sbi, secno))
|
|
|
+ continue;
|
|
|
+
|
|
|
clear_bit(secno, dirty_i->victim_secmap);
|
|
|
return secno * sbi->segs_per_sec;
|
|
|
}
|
|
@@ -322,13 +327,15 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
|
|
|
nsearched++;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
secno = GET_SECNO(sbi, segno);
|
|
|
|
|
|
if (sec_usage_check(sbi, secno))
|
|
|
goto next;
|
|
|
if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap))
|
|
|
goto next;
|
|
|
+ if (gc_type == FG_GC && p.alloc_mode == LFS &&
|
|
|
+ no_fggc_candidate(sbi, secno))
|
|
|
+ goto next;
|
|
|
|
|
|
cost = get_gc_cost(sbi, segno, &p);
|
|
|
|
|
@@ -985,5 +992,16 @@ stop:
|
|
|
|
|
|
void build_gc_manager(struct f2fs_sb_info *sbi)
|
|
|
{
|
|
|
+ u64 main_count, resv_count, ovp_count, blocks_per_sec;
|
|
|
+
|
|
|
DIRTY_I(sbi)->v_ops = &default_v_ops;
|
|
|
+
|
|
|
+ /* threshold of # of valid blocks in a section for victims of FG_GC */
|
|
|
+ main_count = SM_I(sbi)->main_segments << sbi->log_blocks_per_seg;
|
|
|
+ resv_count = SM_I(sbi)->reserved_segments << sbi->log_blocks_per_seg;
|
|
|
+ ovp_count = SM_I(sbi)->ovp_segments << sbi->log_blocks_per_seg;
|
|
|
+ blocks_per_sec = sbi->blocks_per_seg * sbi->segs_per_sec;
|
|
|
+
|
|
|
+ sbi->fggc_threshold = div_u64((main_count - ovp_count) * blocks_per_sec,
|
|
|
+ (main_count - resv_count));
|
|
|
}
|