aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2013-06-01 03:20:26 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-06-06 01:20:46 -0400
commitb2b3460a9404136e0a99b9f7cb56e08ec41ea933 (patch)
tree7e3385fba02fb10ebacecaa3a5c3c7edfcabf44e /fs/f2fs
parent1e03e38b35b8e72d65fd5d931627bd6ff02926c1 (diff)
f2fs: reorganise the function get_victim_by_default
Fix the function get_victim_by_default, where it checks for the condition that p.min_segno != NULL_SEGNO as shown: if (p.min_segno != NULL_SEGNO) goto got_it; and if above condition is true then got_it: if (p.min_segno != NULL_SEGNO) { So this condition is being checked twice. Hence move the goto statement after the if condition so that duplication of condition check is avoided. Also this function makes a call to get_max_cost() to compute the max cost based on the f2fs_sbi_info and victim policy. Since get_max_cost depends on on three parameters of victim_sel_policy => alloc_mode, gc_mode & ofs_unit, once this victim policy is initialised, these value will not change till the execution time of get_victim_by_default() & also f2fs_sbi_info structure parameters will not change. Hence making calls to get_max_cost() in while loop does not seems to be a good point. Instead we can call it once in begining and store the results in local variable, which later can serve our purpose for comparing the cost with max cost inside the while loop. Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Pankaj Kumar <pankaj.km@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/gc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index ddc2c6750eee..3a9df36491a5 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -241,14 +241,14 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
241{ 241{
242 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); 242 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
243 struct victim_sel_policy p; 243 struct victim_sel_policy p;
244 unsigned int secno; 244 unsigned int secno, max_cost;
245 int nsearched = 0; 245 int nsearched = 0;
246 246
247 p.alloc_mode = alloc_mode; 247 p.alloc_mode = alloc_mode;
248 select_policy(sbi, gc_type, type, &p); 248 select_policy(sbi, gc_type, type, &p);
249 249
250 p.min_segno = NULL_SEGNO; 250 p.min_segno = NULL_SEGNO;
251 p.min_cost = get_max_cost(sbi, &p); 251 p.min_cost = max_cost = get_max_cost(sbi, &p);
252 252
253 mutex_lock(&dirty_i->seglist_lock); 253 mutex_lock(&dirty_i->seglist_lock);
254 254
@@ -287,7 +287,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
287 p.min_cost = cost; 287 p.min_cost = cost;
288 } 288 }
289 289
290 if (cost == get_max_cost(sbi, &p)) 290 if (cost == max_cost)
291 continue; 291 continue;
292 292
293 if (nsearched++ >= MAX_VICTIM_SEARCH) { 293 if (nsearched++ >= MAX_VICTIM_SEARCH) {
@@ -295,8 +295,8 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
295 break; 295 break;
296 } 296 }
297 } 297 }
298got_it:
299 if (p.min_segno != NULL_SEGNO) { 298 if (p.min_segno != NULL_SEGNO) {
299got_it:
300 if (p.alloc_mode == LFS) { 300 if (p.alloc_mode == LFS) {
301 secno = GET_SECNO(sbi, p.min_segno); 301 secno = GET_SECNO(sbi, p.min_segno);
302 if (gc_type == FG_GC) 302 if (gc_type == FG_GC)