diff options
author | Namjae Jeon <namjae.jeon@samsung.com> | 2013-08-04 10:10:15 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-08-06 09:00:18 -0400 |
commit | d2dc095f4280ad5fdea33769e8e119fd16648426 (patch) | |
tree | f97a7bd3a06822c463e678770fb63dab52d0bc94 /fs/f2fs/gc.c | |
parent | b59d0bae6ca30c496f298881616258f9cde0d9c6 (diff) |
f2fs: add sysfs entries to select the gc policy
Add sysfs entry gc_idle to control the gc policy. Where
gc_idle = 1 corresponds to selecting a cost benefit approach,
while gc_idle = 2 corresponds to selecting a greedy approach
to garbage collection. The selection is mutually exclusive one
approach will work at any point. If gc_idle = 0, then this
option is disabled.
Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Pankaj Kumar <pankaj.km@samsung.com>
Reviewed-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: change the select_gc_type() flow slightly]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/gc.c')
-rw-r--r-- | fs/f2fs/gc.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 60d4f674efa7..d286d8be8e68 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c | |||
@@ -106,6 +106,8 @@ int start_gc_thread(struct f2fs_sb_info *sbi) | |||
106 | gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME; | 106 | gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME; |
107 | gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME; | 107 | gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME; |
108 | 108 | ||
109 | gc_th->gc_idle = 0; | ||
110 | |||
109 | sbi->gc_thread = gc_th; | 111 | sbi->gc_thread = gc_th; |
110 | init_waitqueue_head(&sbi->gc_thread->gc_wait_queue_head); | 112 | init_waitqueue_head(&sbi->gc_thread->gc_wait_queue_head); |
111 | sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi, | 113 | sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi, |
@@ -130,9 +132,17 @@ void stop_gc_thread(struct f2fs_sb_info *sbi) | |||
130 | sbi->gc_thread = NULL; | 132 | sbi->gc_thread = NULL; |
131 | } | 133 | } |
132 | 134 | ||
133 | static int select_gc_type(int gc_type) | 135 | static int select_gc_type(struct f2fs_gc_kthread *gc_th, int gc_type) |
134 | { | 136 | { |
135 | return (gc_type == BG_GC) ? GC_CB : GC_GREEDY; | 137 | int gc_mode = (gc_type == BG_GC) ? GC_CB : GC_GREEDY; |
138 | |||
139 | if (gc_th && gc_th->gc_idle) { | ||
140 | if (gc_th->gc_idle == 1) | ||
141 | gc_mode = GC_CB; | ||
142 | else if (gc_th->gc_idle == 2) | ||
143 | gc_mode = GC_GREEDY; | ||
144 | } | ||
145 | return gc_mode; | ||
136 | } | 146 | } |
137 | 147 | ||
138 | static void select_policy(struct f2fs_sb_info *sbi, int gc_type, | 148 | static void select_policy(struct f2fs_sb_info *sbi, int gc_type, |
@@ -145,7 +155,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, | |||
145 | p->dirty_segmap = dirty_i->dirty_segmap[type]; | 155 | p->dirty_segmap = dirty_i->dirty_segmap[type]; |
146 | p->ofs_unit = 1; | 156 | p->ofs_unit = 1; |
147 | } else { | 157 | } else { |
148 | p->gc_mode = select_gc_type(gc_type); | 158 | p->gc_mode = select_gc_type(sbi->gc_thread, gc_type); |
149 | p->dirty_segmap = dirty_i->dirty_segmap[DIRTY]; | 159 | p->dirty_segmap = dirty_i->dirty_segmap[DIRTY]; |
150 | p->ofs_unit = sbi->segs_per_sec; | 160 | p->ofs_unit = sbi->segs_per_sec; |
151 | } | 161 | } |