diff options
| author | Park Ju Hyung <qkrwngud825@gmail.com> | 2017-09-26 18:17:32 +0900 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2018-05-23 19:11:36 +0200 |
| commit | 014cdba8459b8031348d03e0924ecd1c1fd7b873 (patch) | |
| tree | 38bbea30bf16f37a47ab3a7c91b375d044a97fe3 /fs | |
| parent | 42b0ee258c44f83cc82f1166f9745ada0afcd03d (diff) | |
f2fs: don't trigger rapid GC repeatedly
Wait until invalid blocks to reach 3% of utilization before triggering rapid GC
to avoid unnecessarily aggressive GC.
We use 3% from (total - written) to avoid GC not doing its job
when the storage gets nearly full.
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/f2fs/gc.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 917bff037..e54e4830d 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -209,16 +209,29 @@ void stop_gc_thread(struct f2fs_sb_info *sbi) static LIST_HEAD(f2fs_sbi_list); static DEFINE_MUTEX(f2fs_sbi_mutex); +/* Trigger rapid GC when invalid block is higher than 3% */ +#define RAPID_GC_LIMIT_INVALID_BLOCK 3 void start_all_gc_threads(void) { struct f2fs_sb_info *sbi; + block_t invalid_blocks; mutex_lock(&f2fs_sbi_mutex); list_for_each_entry(sbi, &f2fs_sbi_list, list) { - start_gc_thread(sbi); - sbi->gc_thread->gc_wake = 1; - wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head); + invalid_blocks = sbi->user_block_count - + written_block_count(sbi) - + free_user_blocks(sbi); + if (invalid_blocks > + ((long)((sbi->user_block_count - written_block_count(sbi)) * + RAPID_GC_LIMIT_INVALID_BLOCK) / 100)) { + start_gc_thread(sbi); + sbi->gc_thread->gc_wake = 1; + wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head); + } else { + pr_info("f2fs: invalid blocks lower than %d%%, skipping rapid GC (%u / (%u - %u))\n", + RAPID_GC_LIMIT_INVALID_BLOCK, invalid_blocks, sbi->user_block_count, written_block_count(sbi)); + } } mutex_unlock(&f2fs_sbi_mutex); } |
