Skip to content

Commit d98af5f

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: introduce gc_urgent_mid mode
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]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent d284af4 commit d98af5f

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,16 @@ Description: Shows current reserved blocks in system, it may be temporarily
297297
What: /sys/fs/f2fs/<disk>/gc_urgent
298298
Date: August 2017
299299
Contact: "Jaegeuk Kim" <[email protected]>
300-
Description: Do background GC aggressively when set. When gc_urgent = 1,
301-
background thread starts to do GC by given gc_urgent_sleep_time
302-
interval. When gc_urgent = 2, F2FS will lower the bar of
303-
checking idle in order to process outstanding discard commands
304-
and GC a little bit aggressively. It is set to 0 by default.
300+
Description: Do background GC aggressively when set. Set to 0 by default.
301+
gc urgent high(1): does GC forcibly in a period of given
302+
gc_urgent_sleep_time and ignores I/O idling check. uses greedy
303+
GC approach and turns SSR mode on.
304+
gc urgent low(2): lowers the bar of checking I/O idling in
305+
order to process outstanding discard commands and GC a
306+
little bit aggressively. uses cost benefit GC approach.
307+
gc urgent mid(3): does GC forcibly in a period of given
308+
gc_urgent_sleep_time and executes a mid level of I/O idling check.
309+
uses cost benefit GC approach.
305310

306311
What: /sys/fs/f2fs/<disk>/gc_urgent_sleep_time
307312
Date: August 2017
@@ -532,7 +537,7 @@ Date: July 2021
532537
Contact: "Daeho Jeong" <[email protected]>
533538
Description: Show how many segments have been reclaimed by GC during a specific
534539
GC mode (0: GC normal, 1: GC idle CB, 2: GC idle greedy,
535-
3: GC idle AT, 4: GC urgent high, 5: GC urgent low)
540+
3: GC idle AT, 4: GC urgent high, 5: GC urgent low 6: GC urgent mid)
536541
You can re-initialize this value to "0".
537542

538543
What: /sys/fs/f2fs/<disk>/gc_segment_mode

fs/f2fs/debug.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,14 @@ static int stat_show(struct seq_file *s, void *v)
476476
si->node_segs, si->bg_node_segs);
477477
seq_printf(s, " - Reclaimed segs : Normal (%d), Idle CB (%d), "
478478
"Idle Greedy (%d), Idle AT (%d), "
479-
"Urgent High (%d), Urgent Low (%d)\n",
479+
"Urgent High (%d), Urgent Mid (%d), "
480+
"Urgent Low (%d)\n",
480481
si->sbi->gc_reclaimed_segs[GC_NORMAL],
481482
si->sbi->gc_reclaimed_segs[GC_IDLE_CB],
482483
si->sbi->gc_reclaimed_segs[GC_IDLE_GREEDY],
483484
si->sbi->gc_reclaimed_segs[GC_IDLE_AT],
484485
si->sbi->gc_reclaimed_segs[GC_URGENT_HIGH],
486+
si->sbi->gc_reclaimed_segs[GC_URGENT_MID],
485487
si->sbi->gc_reclaimed_segs[GC_URGENT_LOW]);
486488
seq_printf(s, "Try to move %d blocks (BG: %d)\n", si->tot_blks,
487489
si->bg_data_blks + si->bg_node_blks);

fs/f2fs/f2fs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ enum {
13131313
GC_IDLE_AT,
13141314
GC_URGENT_HIGH,
13151315
GC_URGENT_LOW,
1316+
GC_URGENT_MID,
13161317
MAX_GC_MODE,
13171318
};
13181319

@@ -2784,6 +2785,9 @@ static inline bool is_idle(struct f2fs_sb_info *sbi, int type)
27842785
if (is_inflight_io(sbi, type))
27852786
return false;
27862787

2788+
if (sbi->gc_mode == GC_URGENT_MID)
2789+
return true;
2790+
27872791
if (sbi->gc_mode == GC_URGENT_LOW &&
27882792
(type == DISCARD_TIME || type == GC_TIME))
27892793
return true;

fs/f2fs/gc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ static int gc_thread_func(void *data)
103103
sbi->gc_urgent_high_remaining--;
104104
}
105105
spin_unlock(&sbi->gc_urgent_high_lock);
106+
}
106107

108+
if (sbi->gc_mode == GC_URGENT_HIGH ||
109+
sbi->gc_mode == GC_URGENT_MID) {
107110
wait_ms = gc_th->urgent_sleep_time;
108111
f2fs_down_write(&sbi->gc_lock);
109112
goto do_gc;

fs/f2fs/sysfs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
468468
}
469469
} else if (t == 2) {
470470
sbi->gc_mode = GC_URGENT_LOW;
471+
} else if (t == 3) {
472+
sbi->gc_mode = GC_URGENT_MID;
473+
if (sbi->gc_thread) {
474+
sbi->gc_thread->gc_wake = 1;
475+
wake_up_interruptible_all(
476+
&sbi->gc_thread->gc_wait_queue_head);
477+
}
471478
} else {
472479
return -EINVAL;
473480
}

0 commit comments

Comments
 (0)