]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: add gc_boost_gc_multiple sysfs node
authorDaeho Jeong <daehojeong@google.com>
Mon, 28 Jul 2025 16:45:44 +0000 (09:45 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 29 Jul 2025 15:02:33 +0000 (15:02 +0000)
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 <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
fs/f2fs/gc.c
fs/f2fs/gc.h
fs/f2fs/sysfs.c

index c2a233f2a085ae69e5c434c62beaaa524d31d3b5..b0026d42dbe89327453360d86503580e47be7def 100644 (file)
@@ -870,3 +870,10 @@ Description:       This threshold is used to control triggering garbage collection whi
                reserved section before preallocating on pinned file.
                By default, the value is ovp_sections, especially, for zoned ufs, the
                value is 1.
+
+What:          /sys/fs/f2fs/<disk>/gc_boost_gc_multiple
+Date:          June 2025
+Contact:       "Daeho Jeong" <daehojeong@google.com>
+Description:   Set a multiplier for the background GC migration window when F2FS GC is
+               boosted. The range should be from 1 to the segment count in a section.
+               Default: 5
index 18b9db2e98ba5c28a8ed974ae1ff7656546a8c73..a9d606b11a3be67a1b06a6197207ebda042ea583 100644 (file)
@@ -197,6 +197,7 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
 
        gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME;
        gc_th->valid_thresh_ratio = DEF_GC_THREAD_VALID_THRESH_RATIO;
+       gc_th->boost_gc_multiple = BOOST_GC_MULTIPLE;
 
        if (f2fs_sb_has_blkzoned(sbi)) {
                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,
                                        !has_enough_free_blocks(sbi,
                                        sbi->gc_thread->boost_zoned_gc_percent))
                                window_granularity *=
-                                       BOOST_GC_MULTIPLE;
+                                       sbi->gc_thread->boost_gc_multiple;
 
                        end_segno = start_segno + window_granularity;
                }
index 11fba7636af7dae92cc91ebc9722e33ede836da0..d7573108bb68ac094a56fc9c947eec55ba201096 100644 (file)
@@ -68,6 +68,7 @@ struct f2fs_gc_kthread {
        unsigned int no_zoned_gc_percent;
        unsigned int boost_zoned_gc_percent;
        unsigned int valid_thresh_ratio;
+       unsigned int boost_gc_multiple;
 };
 
 struct gc_inode_list {
index bdef926b33771ccf8a47cc000f7e4f4b5527438e..d11e8af7306d129433a473d1a3a4b859309a22b1 100644 (file)
@@ -852,6 +852,13 @@ out:
                return count;
        }
 
+       if (!strcmp(a->attr.name, "gc_boost_gc_multiple")) {
+               if (t < 1 || t > SEGS_PER_SEC(sbi))
+                       return -EINVAL;
+               sbi->gc_thread->boost_gc_multiple = (unsigned int)t;
+               return count;
+       }
+
        *ui = (unsigned int)t;
 
        return count;
@@ -1078,6 +1085,7 @@ GC_THREAD_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time);
 GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent);
 GC_THREAD_RW_ATTR(gc_boost_zoned_gc_percent, boost_zoned_gc_percent);
 GC_THREAD_RW_ATTR(gc_valid_thresh_ratio, valid_thresh_ratio);
+GC_THREAD_RW_ATTR(gc_boost_gc_multiple, boost_gc_multiple);
 
 /* SM_INFO ATTR */
 SM_INFO_RW_ATTR(reclaim_segments, rec_prefree_segments);
@@ -1249,6 +1257,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(gc_no_zoned_gc_percent),
        ATTR_LIST(gc_boost_zoned_gc_percent),
        ATTR_LIST(gc_valid_thresh_ratio),
+       ATTR_LIST(gc_boost_gc_multiple),
        ATTR_LIST(gc_idle),
        ATTR_LIST(gc_urgent),
        ATTR_LIST(reclaim_segments),