aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-fs-f2fs6
-rw-r--r--Documentation/filesystems/f2fs.txt6
-rw-r--r--fs/f2fs/gc.c16
-rw-r--r--fs/f2fs/gc.h3
-rw-r--r--fs/f2fs/super.c2
5 files changed, 30 insertions, 3 deletions
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 98e53a09530a..31942efcaf0e 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -18,3 +18,9 @@ Contact: "Namjae Jeon" <namjae.jeon@samsung.com>
18Description: 18Description:
19 Controls the default sleep time for gc_thread. Time 19 Controls the default sleep time for gc_thread. Time
20 is in milliseconds. 20 is in milliseconds.
21
22What: /sys/fs/f2fs/<disk>/gc_idle
23Date: July 2013
24Contact: "Namjae Jeon" <namjae.jeon@samsung.com>
25Description:
26 Controls the victim selection policy for garbage collection.
diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
index 5daf3bb2eef9..3cd27bed6349 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -158,6 +158,12 @@ Files in /sys/fs/f2fs/<devname>
158 time for the garbage collection thread. Time is 158 time for the garbage collection thread. Time is
159 in milliseconds. 159 in milliseconds.
160 160
161 gc_idle This parameter controls the selection of victim
162 policy for garbage collection. Setting gc_idle = 0
163 (default) will disable this option. Setting
164 gc_idle = 1 will select the Cost Benefit approach
165 & setting gc_idle = 2 will select the greedy aproach.
166
161================================================================================ 167================================================================================
162USAGE 168USAGE
163================================================================================ 169================================================================================
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
133static int select_gc_type(int gc_type) 135static 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
138static void select_policy(struct f2fs_sb_info *sbi, int gc_type, 148static 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 }
diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
index f4bf44c9deda..c22dee9f1422 100644
--- a/fs/f2fs/gc.h
+++ b/fs/f2fs/gc.h
@@ -30,6 +30,9 @@ struct f2fs_gc_kthread {
30 unsigned int min_sleep_time; 30 unsigned int min_sleep_time;
31 unsigned int max_sleep_time; 31 unsigned int max_sleep_time;
32 unsigned int no_gc_sleep_time; 32 unsigned int no_gc_sleep_time;
33
34 /* for changing gc mode */
35 unsigned int gc_idle;
33}; 36};
34 37
35struct inode_entry { 38struct inode_entry {
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index e161a24fbf39..94c0e2049546 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -148,12 +148,14 @@ static struct f2fs_attr f2fs_attr_##_name = { \
148F2FS_RW_ATTR(gc_min_sleep_time, min_sleep_time); 148F2FS_RW_ATTR(gc_min_sleep_time, min_sleep_time);
149F2FS_RW_ATTR(gc_max_sleep_time, max_sleep_time); 149F2FS_RW_ATTR(gc_max_sleep_time, max_sleep_time);
150F2FS_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time); 150F2FS_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time);
151F2FS_RW_ATTR(gc_idle, gc_idle);
151 152
152#define ATTR_LIST(name) (&f2fs_attr_##name.attr) 153#define ATTR_LIST(name) (&f2fs_attr_##name.attr)
153static struct attribute *f2fs_attrs[] = { 154static struct attribute *f2fs_attrs[] = {
154 ATTR_LIST(gc_min_sleep_time), 155 ATTR_LIST(gc_min_sleep_time),
155 ATTR_LIST(gc_max_sleep_time), 156 ATTR_LIST(gc_max_sleep_time),
156 ATTR_LIST(gc_no_gc_sleep_time), 157 ATTR_LIST(gc_no_gc_sleep_time),
158 ATTR_LIST(gc_idle),
157 NULL, 159 NULL,
158}; 160};
159 161