@@ -384,14 +384,15 @@ static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno)
384
384
}
385
385
386
386
static inline unsigned int get_gc_cost (struct f2fs_sb_info * sbi ,
387
- unsigned int segno , struct victim_sel_policy * p )
387
+ unsigned int segno , struct victim_sel_policy * p ,
388
+ unsigned int valid_thresh_ratio )
388
389
{
389
390
if (p -> alloc_mode == SSR )
390
391
return get_seg_entry (sbi , segno )-> ckpt_valid_blocks ;
391
392
392
- if (p -> one_time_gc && (get_valid_blocks ( sbi , segno , true) >=
393
- CAP_BLKS_PER_SEC ( sbi ) * sbi -> gc_thread -> valid_thresh_ratio /
394
- 100 ))
393
+ if (p -> one_time_gc && (valid_thresh_ratio < 100 ) &&
394
+ ( get_valid_blocks ( sbi , segno , true) >=
395
+ CAP_BLKS_PER_SEC ( sbi ) * valid_thresh_ratio / 100 ))
395
396
return UINT_MAX ;
396
397
397
398
/* alloc_mode == LFS */
@@ -772,6 +773,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
772
773
unsigned int secno , last_victim ;
773
774
unsigned int last_segment ;
774
775
unsigned int nsearched ;
776
+ unsigned int valid_thresh_ratio = 100 ;
775
777
bool is_atgc ;
776
778
int ret = 0 ;
777
779
@@ -781,7 +783,11 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
781
783
p .alloc_mode = alloc_mode ;
782
784
p .age = age ;
783
785
p .age_threshold = sbi -> am .age_threshold ;
784
- p .one_time_gc = one_time ;
786
+ if (one_time ) {
787
+ p .one_time_gc = one_time ;
788
+ if (has_enough_free_secs (sbi , 0 , NR_PERSISTENT_LOG ))
789
+ valid_thresh_ratio = sbi -> gc_thread -> valid_thresh_ratio ;
790
+ }
785
791
786
792
retry :
787
793
select_policy (sbi , gc_type , type , & p );
@@ -907,7 +913,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
907
913
goto next ;
908
914
}
909
915
910
- cost = get_gc_cost (sbi , segno , & p );
916
+ cost = get_gc_cost (sbi , segno , & p , valid_thresh_ratio );
911
917
912
918
if (p .min_cost > cost ) {
913
919
p .min_segno = segno ;
0 commit comments