Commit 6cb968d9b0358c7e807416a85699a526e820083c
1 parent
2af4bd6ca5
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
f2fs: avoid frequent background GC
If there is no victim segments selected by background GC, let's wait a little bit longer time to collect dirty segments. By default, let's give 5 minutes. Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Showing 2 changed files with 9 additions and 6 deletions Side-by-side Diff
fs/f2fs/gc.c
... | ... | @@ -82,9 +82,6 @@ |
82 | 82 | /* if return value is not zero, no victim was selected */ |
83 | 83 | if (f2fs_gc(sbi)) |
84 | 84 | wait_ms = GC_THREAD_NOGC_SLEEP_TIME; |
85 | - else if (wait_ms == GC_THREAD_NOGC_SLEEP_TIME) | |
86 | - wait_ms = GC_THREAD_MAX_SLEEP_TIME; | |
87 | - | |
88 | 85 | } while (!kthread_should_stop()); |
89 | 86 | return 0; |
90 | 87 | } |
fs/f2fs/gc.h
... | ... | @@ -13,9 +13,9 @@ |
13 | 13 | * whether IO subsystem is idle |
14 | 14 | * or not |
15 | 15 | */ |
16 | -#define GC_THREAD_MIN_SLEEP_TIME 10000 /* milliseconds */ | |
17 | -#define GC_THREAD_MAX_SLEEP_TIME 30000 | |
18 | -#define GC_THREAD_NOGC_SLEEP_TIME 10000 | |
16 | +#define GC_THREAD_MIN_SLEEP_TIME 30000 /* milliseconds */ | |
17 | +#define GC_THREAD_MAX_SLEEP_TIME 60000 | |
18 | +#define GC_THREAD_NOGC_SLEEP_TIME 300000 /* wait 5 min */ | |
19 | 19 | #define LIMIT_INVALID_BLOCK 40 /* percentage over total user space */ |
20 | 20 | #define LIMIT_FREE_BLOCK 40 /* percentage over invalid + free space */ |
21 | 21 | |
... | ... | @@ -58,6 +58,9 @@ |
58 | 58 | |
59 | 59 | static inline long increase_sleep_time(long wait) |
60 | 60 | { |
61 | + if (wait == GC_THREAD_NOGC_SLEEP_TIME) | |
62 | + return wait; | |
63 | + | |
61 | 64 | wait += GC_THREAD_MIN_SLEEP_TIME; |
62 | 65 | if (wait > GC_THREAD_MAX_SLEEP_TIME) |
63 | 66 | wait = GC_THREAD_MAX_SLEEP_TIME; |
... | ... | @@ -66,6 +69,9 @@ |
66 | 69 | |
67 | 70 | static inline long decrease_sleep_time(long wait) |
68 | 71 | { |
72 | + if (wait == GC_THREAD_NOGC_SLEEP_TIME) | |
73 | + wait = GC_THREAD_MAX_SLEEP_TIME; | |
74 | + | |
69 | 75 | wait -= GC_THREAD_MIN_SLEEP_TIME; |
70 | 76 | if (wait <= GC_THREAD_MIN_SLEEP_TIME) |
71 | 77 | wait = GC_THREAD_MIN_SLEEP_TIME; |