Skip to content

Commit 1d4c5db

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: add gc_boost_gc_multiple sysfs node
Add a sysfs knob to set a multiplier for the background GC migration window when F2FS Garbage Collection is boosted. Signed-off-by: Daeho Jeong <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1005a3c commit 1d4c5db

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,3 +870,10 @@ Description: This threshold is used to control triggering garbage collection whi
870870
reserved section before preallocating on pinned file.
871871
By default, the value is ovp_sections, especially, for zoned ufs, the
872872
value is 1.
873+
874+
What: /sys/fs/f2fs/<disk>/gc_boost_gc_multiple
875+
Date: June 2025
876+
Contact: "Daeho Jeong" <[email protected]>
877+
Description: Set a multiplier for the background GC migration window when F2FS GC is
878+
boosted. The range should be from 1 to the segment count in a section.
879+
Default: 5

fs/f2fs/gc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
197197

198198
gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME;
199199
gc_th->valid_thresh_ratio = DEF_GC_THREAD_VALID_THRESH_RATIO;
200+
gc_th->boost_gc_multiple = BOOST_GC_MULTIPLE;
200201

201202
if (f2fs_sb_has_blkzoned(sbi)) {
202203
gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED;
@@ -1750,7 +1751,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
17501751
!has_enough_free_blocks(sbi,
17511752
sbi->gc_thread->boost_zoned_gc_percent))
17521753
window_granularity *=
1753-
BOOST_GC_MULTIPLE;
1754+
sbi->gc_thread->boost_gc_multiple;
17541755

17551756
end_segno = start_segno + window_granularity;
17561757
}

fs/f2fs/gc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct f2fs_gc_kthread {
6868
unsigned int no_zoned_gc_percent;
6969
unsigned int boost_zoned_gc_percent;
7070
unsigned int valid_thresh_ratio;
71+
unsigned int boost_gc_multiple;
7172
};
7273

7374
struct gc_inode_list {

fs/f2fs/sysfs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
852852
return count;
853853
}
854854

855+
if (!strcmp(a->attr.name, "gc_boost_gc_multiple")) {
856+
if (t < 1 || t > SEGS_PER_SEC(sbi))
857+
return -EINVAL;
858+
sbi->gc_thread->boost_gc_multiple = (unsigned int)t;
859+
return count;
860+
}
861+
855862
*ui = (unsigned int)t;
856863

857864
return count;
@@ -1078,6 +1085,7 @@ GC_THREAD_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time);
10781085
GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent);
10791086
GC_THREAD_RW_ATTR(gc_boost_zoned_gc_percent, boost_zoned_gc_percent);
10801087
GC_THREAD_RW_ATTR(gc_valid_thresh_ratio, valid_thresh_ratio);
1088+
GC_THREAD_RW_ATTR(gc_boost_gc_multiple, boost_gc_multiple);
10811089

10821090
/* SM_INFO ATTR */
10831091
SM_INFO_RW_ATTR(reclaim_segments, rec_prefree_segments);
@@ -1249,6 +1257,7 @@ static struct attribute *f2fs_attrs[] = {
12491257
ATTR_LIST(gc_no_zoned_gc_percent),
12501258
ATTR_LIST(gc_boost_zoned_gc_percent),
12511259
ATTR_LIST(gc_valid_thresh_ratio),
1260+
ATTR_LIST(gc_boost_gc_multiple),
12521261
ATTR_LIST(gc_idle),
12531262
ATTR_LIST(gc_urgent),
12541263
ATTR_LIST(reclaim_segments),

0 commit comments

Comments
 (0)