aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/f2fs/gc.c8
-rw-r--r--fs/f2fs/gc.h2
-rw-r--r--fs/f2fs/segment.h1
3 files changed, 9 insertions, 2 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index eb89037e3312..2f157e883687 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -153,12 +153,18 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
153 if (p->alloc_mode == SSR) { 153 if (p->alloc_mode == SSR) {
154 p->gc_mode = GC_GREEDY; 154 p->gc_mode = GC_GREEDY;
155 p->dirty_segmap = dirty_i->dirty_segmap[type]; 155 p->dirty_segmap = dirty_i->dirty_segmap[type];
156 p->max_search = dirty_i->nr_dirty[type];
156 p->ofs_unit = 1; 157 p->ofs_unit = 1;
157 } else { 158 } else {
158 p->gc_mode = select_gc_type(sbi->gc_thread, gc_type); 159 p->gc_mode = select_gc_type(sbi->gc_thread, gc_type);
159 p->dirty_segmap = dirty_i->dirty_segmap[DIRTY]; 160 p->dirty_segmap = dirty_i->dirty_segmap[DIRTY];
161 p->max_search = dirty_i->nr_dirty[DIRTY];
160 p->ofs_unit = sbi->segs_per_sec; 162 p->ofs_unit = sbi->segs_per_sec;
161 } 163 }
164
165 if (p->max_search > MAX_VICTIM_SEARCH)
166 p->max_search = MAX_VICTIM_SEARCH;
167
162 p->offset = sbi->last_victim[p->gc_mode]; 168 p->offset = sbi->last_victim[p->gc_mode];
163} 169}
164 170
@@ -305,7 +311,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
305 if (cost == max_cost) 311 if (cost == max_cost)
306 continue; 312 continue;
307 313
308 if (nsearched++ >= MAX_VICTIM_SEARCH) { 314 if (nsearched++ >= p.max_search) {
309 sbi->last_victim[p.gc_mode] = segno; 315 sbi->last_victim[p.gc_mode] = segno;
310 break; 316 break;
311 } 317 }
diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
index c22dee9f1422..507056d22205 100644
--- a/fs/f2fs/gc.h
+++ b/fs/f2fs/gc.h
@@ -20,7 +20,7 @@
20#define LIMIT_FREE_BLOCK 40 /* percentage over invalid + free space */ 20#define LIMIT_FREE_BLOCK 40 /* percentage over invalid + free space */
21 21
22/* Search max. number of dirty segments to select a victim segment */ 22/* Search max. number of dirty segments to select a victim segment */
23#define MAX_VICTIM_SEARCH 20 23#define MAX_VICTIM_SEARCH 4096 /* covers 8GB */
24 24
25struct f2fs_gc_kthread { 25struct f2fs_gc_kthread {
26 struct task_struct *f2fs_gc_task; 26 struct task_struct *f2fs_gc_task;
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index e0d6d3abf396..bdd10eab8c40 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -142,6 +142,7 @@ struct victim_sel_policy {
142 int alloc_mode; /* LFS or SSR */ 142 int alloc_mode; /* LFS or SSR */
143 int gc_mode; /* GC_CB or GC_GREEDY */ 143 int gc_mode; /* GC_CB or GC_GREEDY */
144 unsigned long *dirty_segmap; /* dirty segment bitmap */ 144 unsigned long *dirty_segmap; /* dirty segment bitmap */
145 unsigned int max_search; /* maximum # of segments to search */
145 unsigned int offset; /* last scanned bitmap offset */ 146 unsigned int offset; /* last scanned bitmap offset */
146 unsigned int ofs_unit; /* bitmap search unit */ 147 unsigned int ofs_unit; /* bitmap search unit */
147 unsigned int min_cost; /* minimum cost */ 148 unsigned int min_cost; /* minimum cost */