Skip to content

Commit e462fc4

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: maintain one time GC mode is enabled during whole zoned GC cycle
The current version missed setting one time GC for normal zoned GC cycle. So, valid threshold control is not working. Need to fix it to prevent excessive GC for zoned devices. Fixes: e791d00 ("f2fs: add valid block ratio not to do excessive GC for one time GC") Signed-off-by: Daeho Jeong <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent d281851 commit e462fc4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

fs/f2fs/gc.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,27 @@ static int gc_thread_func(void *data)
3838
struct f2fs_gc_control gc_control = {
3939
.victim_segno = NULL_SEGNO,
4040
.should_migrate_blocks = false,
41-
.err_gc_skipped = false };
41+
.err_gc_skipped = false,
42+
.one_time = false };
4243

4344
wait_ms = gc_th->min_sleep_time;
4445

4546
set_freezable();
4647
do {
47-
bool sync_mode, foreground = false;
48+
bool sync_mode, foreground = false, gc_boost = false;
4849

4950
wait_event_freezable_timeout(*wq,
5051
kthread_should_stop() ||
5152
waitqueue_active(fggc_wq) ||
5253
gc_th->gc_wake,
5354
msecs_to_jiffies(wait_ms));
5455

55-
if (test_opt(sbi, GC_MERGE) && waitqueue_active(fggc_wq))
56+
if (test_opt(sbi, GC_MERGE) && waitqueue_active(fggc_wq)) {
5657
foreground = true;
58+
gc_control.one_time = false;
59+
} else if (f2fs_sb_has_blkzoned(sbi)) {
60+
gc_control.one_time = true;
61+
}
5762

5863
/* give it a try one time */
5964
if (gc_th->gc_wake)
@@ -81,8 +86,6 @@ static int gc_thread_func(void *data)
8186
continue;
8287
}
8388

84-
gc_control.one_time = false;
85-
8689
/*
8790
* [GC triggering condition]
8891
* 0. GC is not conducted currently.
@@ -132,7 +135,7 @@ static int gc_thread_func(void *data)
132135
if (need_to_boost_gc(sbi)) {
133136
decrease_sleep_time(gc_th, &wait_ms);
134137
if (f2fs_sb_has_blkzoned(sbi))
135-
gc_control.one_time = true;
138+
gc_boost = true;
136139
} else {
137140
increase_sleep_time(gc_th, &wait_ms);
138141
}
@@ -141,7 +144,7 @@ static int gc_thread_func(void *data)
141144
FOREGROUND : BACKGROUND);
142145

143146
sync_mode = (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC) ||
144-
(gc_control.one_time && gc_th->boost_gc_greedy);
147+
(gc_boost && gc_th->boost_gc_greedy);
145148

146149
/* foreground GC was been triggered via f2fs_balance_fs() */
147150
if (foreground && !f2fs_sb_has_blkzoned(sbi))

0 commit comments

Comments
 (0)