diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-18 16:34:38 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-22 21:39:59 -0800 |
commit | 4ce537763eeb6b9d453f84b70c69c609973ccc1e (patch) | |
tree | 523de2afa9148b2016ba58f802f93c2595bd4827 /fs/f2fs/gc.c | |
parent | 8060656aa337f7cd34f1818b24417e8a7a00f4a5 (diff) | |
download | linux-4ce537763eeb6b9d453f84b70c69c609973ccc1e.tar.gz linux-4ce537763eeb6b9d453f84b70c69c609973ccc1e.tar.bz2 linux-4ce537763eeb6b9d453f84b70c69c609973ccc1e.zip |
f2fs: remain last victim segment number ascending order
This patch avoids to remain inefficient victim segment number selected by
a victim.
For example, if all the dirty segments has same valid blocks, we can get
the victim segments descending order due to keeping wrong last segment number.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/gc.c')
-rw-r--r-- | fs/f2fs/gc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 47ade3542fbd..c01353429ba0 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -270,7 +270,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); struct victim_sel_policy p; - unsigned int secno, max_cost; + unsigned int secno, max_cost, last_victim; unsigned int last_segment = MAIN_SEGS(sbi); unsigned int nsearched = 0; @@ -285,6 +285,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, if (p.max_search == 0) goto out; + last_victim = sbi->last_victim[p.gc_mode]; if (p.alloc_mode == LFS && gc_type == FG_GC) { p.min_segno = check_bg_victims(sbi); if (p.min_segno != NULL_SEGNO) @@ -332,7 +333,10 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, } next: if (nsearched >= p.max_search) { - sbi->last_victim[p.gc_mode] = segno; + if (!sbi->last_victim[p.gc_mode] && segno <= last_victim) + sbi->last_victim[p.gc_mode] = last_victim + 1; + else + sbi->last_victim[p.gc_mode] = segno + 1; break; } } |