@@ -81,6 +81,8 @@ static int gc_thread_func(void *data)
81
81
continue ;
82
82
}
83
83
84
+ gc_control .one_time = false;
85
+
84
86
/*
85
87
* [GC triggering condition]
86
88
* 0. GC is not conducted currently.
@@ -126,15 +128,19 @@ static int gc_thread_func(void *data)
126
128
wait_ms = gc_th -> max_sleep_time ;
127
129
}
128
130
129
- if (need_to_boost_gc (sbi ))
131
+ if (need_to_boost_gc (sbi )) {
130
132
decrease_sleep_time (gc_th , & wait_ms );
131
- else
133
+ if (f2fs_sb_has_blkzoned (sbi ))
134
+ gc_control .one_time = true;
135
+ } else {
132
136
increase_sleep_time (gc_th , & wait_ms );
137
+ }
133
138
do_gc :
134
139
stat_inc_gc_call_count (sbi , foreground ?
135
140
FOREGROUND : BACKGROUND );
136
141
137
- sync_mode = F2FS_OPTION (sbi ).bggc_mode == BGGC_MODE_SYNC ;
142
+ sync_mode = (F2FS_OPTION (sbi ).bggc_mode == BGGC_MODE_SYNC ) ||
143
+ gc_control .one_time ;
138
144
139
145
/* foreground GC was been triggered via f2fs_balance_fs() */
140
146
if (foreground )
@@ -1701,7 +1707,7 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim,
1701
1707
static int do_garbage_collect (struct f2fs_sb_info * sbi ,
1702
1708
unsigned int start_segno ,
1703
1709
struct gc_inode_list * gc_list , int gc_type ,
1704
- bool force_migrate )
1710
+ bool force_migrate , bool one_time )
1705
1711
{
1706
1712
struct page * sum_page ;
1707
1713
struct f2fs_summary_block * sum ;
@@ -1728,7 +1734,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
1728
1734
sec_end_segno -= SEGS_PER_SEC (sbi ) -
1729
1735
f2fs_usable_segs_in_sec (sbi , segno );
1730
1736
1731
- if (gc_type == BG_GC ) {
1737
+ if (gc_type == BG_GC || one_time ) {
1732
1738
unsigned int window_granularity =
1733
1739
sbi -> migration_window_granularity ;
1734
1740
@@ -1911,7 +1917,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
1911
1917
}
1912
1918
1913
1919
seg_freed = do_garbage_collect (sbi , segno , & gc_list , gc_type ,
1914
- gc_control -> should_migrate_blocks );
1920
+ gc_control -> should_migrate_blocks ,
1921
+ gc_control -> one_time );
1915
1922
if (seg_freed < 0 )
1916
1923
goto stop ;
1917
1924
@@ -1922,6 +1929,9 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
1922
1929
total_sec_freed ++ ;
1923
1930
}
1924
1931
1932
+ if (gc_control -> one_time )
1933
+ goto stop ;
1934
+
1925
1935
if (gc_type == FG_GC ) {
1926
1936
sbi -> cur_victim_sec = NULL_SEGNO ;
1927
1937
@@ -2047,7 +2057,7 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi,
2047
2057
};
2048
2058
2049
2059
do_garbage_collect (sbi , segno , & gc_list , FG_GC ,
2050
- dry_run_sections == 0 );
2060
+ dry_run_sections == 0 , false );
2051
2061
put_gc_inode (& gc_list );
2052
2062
2053
2063
if (!dry_run && get_valid_blocks (sbi , segno , true))
0 commit comments