Skip to content

Commit 9a481a1

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: create gc_no_zoned_gc_percent and gc_boost_zoned_gc_percent
Added control knobs for gc_no_zoned_gc_percent and gc_boost_zoned_gc_percent. Signed-off-by: Daeho Jeong <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 9748c2d commit 9a481a1

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,3 +797,17 @@ Date: September 2024
797797
Contact: "Daeho Jeong" <[email protected]>
798798
Description: In order to fine tune GC behavior, we can control the number of
799799
reserved segments.
800+
801+
What: /sys/fs/f2fs/<disk>/gc_no_zoned_gc_percent
802+
Date: September 2024
803+
Contact: "Daeho Jeong" <[email protected]>
804+
Description: If the percentage of free sections over total sections is above this
805+
number, F2FS do not garbage collection for zoned devices through the
806+
background GC thread. the default number is "60".
807+
808+
What: /sys/fs/f2fs/<disk>/gc_boost_zoned_gc_percent
809+
Date: September 2024
810+
Contact: "Daeho Jeong" <[email protected]>
811+
Description: If the percentage of free sections over total sections is under this
812+
number, F2FS boosts garbage collection for zoned devices through the
813+
background GC thread. the default number is "25".

fs/f2fs/gc.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ static int gc_thread_func(void *data)
119119
}
120120

121121
if (f2fs_sb_has_blkzoned(sbi)) {
122-
if (has_enough_free_blocks(sbi, LIMIT_NO_ZONED_GC)) {
122+
if (has_enough_free_blocks(sbi,
123+
gc_th->no_zoned_gc_percent)) {
123124
wait_ms = gc_th->no_gc_sleep_time;
124125
f2fs_up_write(&sbi->gc_lock);
125126
goto next;
@@ -200,10 +201,14 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
200201
gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED;
201202
gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED;
202203
gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED;
204+
gc_th->no_zoned_gc_percent = LIMIT_NO_ZONED_GC;
205+
gc_th->boost_zoned_gc_percent = LIMIT_BOOST_ZONED_GC;
203206
} else {
204207
gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME;
205208
gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME;
206209
gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME;
210+
gc_th->no_zoned_gc_percent = 0;
211+
gc_th->boost_zoned_gc_percent = 0;
207212
}
208213

209214
gc_th->gc_wake = false;
@@ -1740,8 +1745,9 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
17401745

17411746
if (f2fs_sb_has_blkzoned(sbi) &&
17421747
!has_enough_free_blocks(sbi,
1743-
LIMIT_BOOST_ZONED_GC))
1744-
window_granularity *= BOOST_GC_MULTIPLE;
1748+
sbi->gc_thread->boost_zoned_gc_percent))
1749+
window_granularity *=
1750+
BOOST_GC_MULTIPLE;
17451751

17461752
end_segno = start_segno + window_granularity;
17471753
}

fs/f2fs/gc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ struct f2fs_gc_kthread {
6161
* caller of f2fs_balance_fs()
6262
* will wait on this wait queue.
6363
*/
64+
65+
/* for gc control for zoned devices */
66+
unsigned int no_zoned_gc_percent;
67+
unsigned int boost_zoned_gc_percent;
6468
};
6569

6670
struct gc_inode_list {

fs/f2fs/sysfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ GC_THREAD_RW_ATTR(gc_urgent_sleep_time, urgent_sleep_time);
977977
GC_THREAD_RW_ATTR(gc_min_sleep_time, min_sleep_time);
978978
GC_THREAD_RW_ATTR(gc_max_sleep_time, max_sleep_time);
979979
GC_THREAD_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time);
980+
GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent);
981+
GC_THREAD_RW_ATTR(gc_boost_zoned_gc_percent, boost_zoned_gc_percent);
980982

981983
/* SM_INFO ATTR */
982984
SM_INFO_RW_ATTR(reclaim_segments, rec_prefree_segments);
@@ -1137,6 +1139,8 @@ static struct attribute *f2fs_attrs[] = {
11371139
ATTR_LIST(gc_min_sleep_time),
11381140
ATTR_LIST(gc_max_sleep_time),
11391141
ATTR_LIST(gc_no_gc_sleep_time),
1142+
ATTR_LIST(gc_no_zoned_gc_percent),
1143+
ATTR_LIST(gc_boost_zoned_gc_percent),
11401144
ATTR_LIST(gc_idle),
11411145
ATTR_LIST(gc_urgent),
11421146
ATTR_LIST(reclaim_segments),

0 commit comments

Comments
 (0)