Skip to content

Commit c8705ce

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: add gc_boost_gc_greedy sysfs node
Add this to control GC algorithm for boost GC. Signed-off-by: Daeho Jeong <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1d4c5db commit c8705ce

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,3 +877,9 @@ Contact: "Daeho Jeong" <[email protected]>
877877
Description: Set a multiplier for the background GC migration window when F2FS GC is
878878
boosted. The range should be from 1 to the segment count in a section.
879879
Default: 5
880+
881+
What: /sys/fs/f2fs/<disk>/gc_boost_gc_greedy
882+
Date: June 2025
883+
Contact: "Daeho Jeong" <[email protected]>
884+
Description: Control GC algorithm for boost GC. 0: cost benefit, 1: greedy
885+
Default: 1

fs/f2fs/gc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static int gc_thread_func(void *data)
141141
FOREGROUND : BACKGROUND);
142142

143143
sync_mode = (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC) ||
144-
gc_control.one_time;
144+
(gc_control.one_time && gc_th->boost_gc_greedy);
145145

146146
/* foreground GC was been triggered via f2fs_balance_fs() */
147147
if (foreground && !f2fs_sb_has_blkzoned(sbi))
@@ -198,6 +198,7 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
198198
gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME;
199199
gc_th->valid_thresh_ratio = DEF_GC_THREAD_VALID_THRESH_RATIO;
200200
gc_th->boost_gc_multiple = BOOST_GC_MULTIPLE;
201+
gc_th->boost_gc_greedy = GC_GREEDY;
201202

202203
if (f2fs_sb_has_blkzoned(sbi)) {
203204
gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED;

fs/f2fs/gc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct f2fs_gc_kthread {
6969
unsigned int boost_zoned_gc_percent;
7070
unsigned int valid_thresh_ratio;
7171
unsigned int boost_gc_multiple;
72+
unsigned int boost_gc_greedy;
7273
};
7374

7475
struct gc_inode_list {

fs/f2fs/sysfs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
859859
return count;
860860
}
861861

862+
if (!strcmp(a->attr.name, "gc_boost_gc_greedy")) {
863+
if (t > GC_GREEDY)
864+
return -EINVAL;
865+
sbi->gc_thread->boost_gc_greedy = (unsigned int)t;
866+
return count;
867+
}
868+
862869
*ui = (unsigned int)t;
863870

864871
return count;
@@ -1086,6 +1093,7 @@ GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent);
10861093
GC_THREAD_RW_ATTR(gc_boost_zoned_gc_percent, boost_zoned_gc_percent);
10871094
GC_THREAD_RW_ATTR(gc_valid_thresh_ratio, valid_thresh_ratio);
10881095
GC_THREAD_RW_ATTR(gc_boost_gc_multiple, boost_gc_multiple);
1096+
GC_THREAD_RW_ATTR(gc_boost_gc_greedy, boost_gc_greedy);
10891097

10901098
/* SM_INFO ATTR */
10911099
SM_INFO_RW_ATTR(reclaim_segments, rec_prefree_segments);
@@ -1258,6 +1266,7 @@ static struct attribute *f2fs_attrs[] = {
12581266
ATTR_LIST(gc_boost_zoned_gc_percent),
12591267
ATTR_LIST(gc_valid_thresh_ratio),
12601268
ATTR_LIST(gc_boost_gc_multiple),
1269+
ATTR_LIST(gc_boost_gc_greedy),
12611270
ATTR_LIST(gc_idle),
12621271
ATTR_LIST(gc_urgent),
12631272
ATTR_LIST(reclaim_segments),

0 commit comments

Comments
 (0)