f2fs: add gc_boost_gc_multiple sysfs node
PATCH v3 1/1 f2fs: add gc_boost_gc_multiple sysfs node
From: Daeho Jeong <[email protected]>
Add a sysfs knob to set a multiplier for the background GC migration window when F2FS Garbage Collection is boosted.
---
v3: fix the range check condition
v2: limit the available value range
--- Documentation/ABI/testing/sysfs-fs-f2fs | 8 ++++++++ fs/f2fs/gc.c | 3 ++- fs/f2fs/gc.h | 1 + fs/f2fs/sysfs.c | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-fs-f2fs +8 -0
@@ -861,3 +861,11 @@ Description: This is a read-only entry to show the value of sb.s_encoding_flags, SB_ENC_STRICT_MODE_FL 0x00000001 SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002 ============================ ========== + +What: /sys/fs/f2fs/<disk>/gc_boost_gc_multiple +Date: June 2025 +Contact: "Daeho Jeong" <[email protected]> +Description: Set a multiplier for the background GC migration window when F2FS GC is + boosted. + Default: 5 +
fs/f2fs/gc.c +2 -1
@@ -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 ;
@@ -1749,7 +1750,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; }
fs/f2fs/gc.h +1 -0
@@ -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 {
fs/f2fs/sysfs.c +9 -0
@@ -824,6 +824,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,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;
@@ -1050,6 +1057,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);
@@ -1220,6 +1228,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),
Signature · 1 line
2.50.1.470.g6ba607880d-goog
Jaegeuk Kim
maintainerPlease check
https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/log/?h=dev-test
Quoted 102 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
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]>---
v3: fix the range check condition
v2: limit the available value range--- Documentation/ABI/testing/sysfs-fs-f2fs | 8 ++++++++ fs/f2fs/gc.c | 3 ++- fs/f2fs/gc.h | 1 + fs/f2fs/sysfs.c | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-fs-f2fs +8
-0@@ -861,3 +861,11 @@ Description: This is a read-only entry to show the value of sb.s_encoding_flags, SB_ENC_STRICT_MODE_FL 0x00000001 SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002 ============================ ========== + +What: /sys/fs/f2fs/<disk>/gc_boost_gc_multiple +Date: June 2025 +Contact: "Daeho Jeong" <[email protected]> +Description: Set a multiplier for the background GC migration window when F2FS GC is + boosted. + Default: 5 +fs/f2fs/gc.c +2
-1@@ -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 ;@@ -1749,7 +1750,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; }fs/f2fs/gc.h +1
-0@@ -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 {fs/f2fs/sysfs.c +9
-0@@ -824,6 +824,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,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;@@ -1050,6 +1057,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);@@ -1220,6 +1228,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),Signature · 1 line
2.50.1.470.g6ba607880d-goog
Sorry.
The below line should belong to "f2fs: add gc_boost_gc_multiple sysfs node", too.
+ boosted. the range should be from 1 to the segment count in a section.
Quoted 108 lines · Jaegeuk Kim
Please check
https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/log/?h=dev-test
Quoted 102 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
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]>---
v3: fix the range check condition
v2: limit the available value range--- Documentation/ABI/testing/sysfs-fs-f2fs | 8 ++++++++ fs/f2fs/gc.c | 3 ++- fs/f2fs/gc.h | 1 + fs/f2fs/sysfs.c | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-fs-f2fs +8
-0@@ -861,3 +861,11 @@ Description: This is a read-only entry to show the value of sb.s_encoding_flags, SB_ENC_STRICT_MODE_FL 0x00000001 SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002 ============================ ========== + +What: /sys/fs/f2fs/<disk>/gc_boost_gc_multiple +Date: June 2025 +Contact: "Daeho Jeong" <[email protected]> +Description: Set a multiplier for the background GC migration window when F2FS GC is + boosted. + Default: 5 +fs/f2fs/gc.c +2
-1@@ -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 ;@@ -1749,7 +1750,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; }fs/f2fs/gc.h +1
-0@@ -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 {fs/f2fs/sysfs.c +9
-1@@ -824,6 +824,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,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;@@ -1050,6 +1057,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);@@ -1220,6 +1228,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), --2.50.1.470.g6ba607880d-goog