Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
f2fs: introduce gc_urgent_mid mode
Browse files Browse the repository at this point in the history
We need a mid level of gc urgent mode to do GC forcibly in a period
of given gc_urgent_sleep_time, but not like using greedy GC approach
and switching to SSR mode such as gc urgent high mode. This can be
used for more aggressive periodic storage clean up.

Signed-off-by: Daeho Jeong <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
Change-Id: If8b5292fe850300eee400323d9ca2291a3496832
  • Loading branch information
Daeho Jeong authored and reocat committed Jan 5, 2024
1 parent 720d53f commit ef4e822
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
12 changes: 8 additions & 4 deletions Documentation/ABI/testing/sysfs-fs-f2fs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,13 @@ Description: Shows current reserved blocks in system, it may be temporarily
What: /sys/fs/f2fs/<disk>/gc_urgent
Date: August 2017
Contact: "Jaegeuk Kim" <[email protected]>
Description: Do background GC agressively when set. When gc_urgent = 1,
background thread starts to do GC by given gc_urgent_sleep_time
interval. It is set to 0 by default.
Description: Do background GC aggressively when set. Set to 0 by default.
gc urgent(1): does GC forcibly in a period of given
gc_urgent_sleep_time and ignores I/O idling check. uses greedy
GC approach and turns SSR mode on.
gc urgent mid(3): does GC forcibly in a period of given
gc_urgent_sleep_time and executes a mid level of I/O idling check.
uses cost benefit GC approach.

What: /sys/fs/f2fs/<disk>/gc_urgent_sleep_time
Date: August 2017
Expand Down Expand Up @@ -356,7 +360,7 @@ Date: July 2021
Contact: "Daeho Jeong" <[email protected]>
Description: Show how many segments have been reclaimed by GC during a specific
GC mode (0: GC normal, 1: GC idle CB, 2: GC idle greedy, 3: GC idle AT,
4: GC urgent), You can re-initialize this value to "0".
4: GC urgent, 5: GC urgent mid), You can re-initialize this value to "0".

What: /sys/fs/f2fs/<disk>/gc_segment_mode
Date: July 2021
Expand Down
3 changes: 2 additions & 1 deletion fs/f2fs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ static int stat_show(struct seq_file *s, void *v)
seq_printf(s, " - Idle CB : %d\n", si->sbi->gc_reclaimed_segs[GC_IDLE_CB]);
seq_printf(s, " - Idle Greedy : %d\n", si->sbi->gc_reclaimed_segs[GC_IDLE_GREEDY]);
seq_printf(s, " - Idle AT : %d\n", si->sbi->gc_reclaimed_segs[GC_IDLE_AT]);
seq_printf(s, " - Urgent : %d\n", si->sbi->gc_reclaimed_segs[GC_URGENT]);
seq_printf(s, " - Urgent High : %d\n", si->sbi->gc_reclaimed_segs[GC_URGENT]);
seq_printf(s, " - Urgent Mid : %d\n", si->sbi->gc_reclaimed_segs[GC_URGENT_MID]);
seq_printf(s, "Try to move %d blocks (BG: %d)\n", si->tot_blks,
si->bg_data_blks + si->bg_node_blks);
seq_printf(s, " - data blocks : %d (%d)\n", si->data_blks,
Expand Down
4 changes: 4 additions & 0 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ enum {
GC_IDLE_GREEDY,
GC_IDLE_AT,
GC_URGENT,
GC_URGENT_MID,
MAX_GC_MODE,
};

Expand Down Expand Up @@ -2421,6 +2422,9 @@ static inline bool is_idle(struct f2fs_sb_info *sbi, int type)
if (is_inflight_io(sbi, type))
return false;

if (sbi->gc_mode == GC_URGENT_MID)
return true;

return f2fs_time_over(sbi, type);
}

Expand Down
3 changes: 2 additions & 1 deletion fs/f2fs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ static int gc_thread_func(void *data)
* invalidated soon after by user update or deletion.
* So, I'd like to wait some time to collect dirty segments.
*/
if (sbi->gc_mode == GC_URGENT) {
if (sbi->gc_mode == GC_URGENT ||
sbi->gc_mode == GC_URGENT_MID) {
wait_ms = gc_th->urgent_sleep_time;
down_write(&sbi->gc_lock);
goto do_gc;
Expand Down
9 changes: 8 additions & 1 deletion fs/f2fs/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,21 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
return -EINVAL;

if (!strcmp(a->attr.name, "gc_urgent")) {
if (t >= 1) {
if (t == 1) {
sbi->gc_mode = GC_URGENT;
if (sbi->gc_thread) {
sbi->gc_thread->gc_wake = 1;
wake_up_interruptible_all(
&sbi->gc_thread->gc_wait_queue_head);
wake_up_discard_thread(sbi, true);
}
} else if (t == 3) {
sbi->gc_mode = GC_URGENT_MID;
if (sbi->gc_thread) {
sbi->gc_thread->gc_wake = 1;
wake_up_interruptible_all(
&sbi->gc_thread->gc_wait_queue_head);
}
} else {
sbi->gc_mode = GC_NORMAL;
}
Expand Down

0 comments on commit ef4e822

Please sign in to comment.