diff options
author | Chao Yu <yuchao0@huawei.com> | 2016-08-19 23:13:46 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-08-29 18:31:08 -0700 |
commit | 43ced84ec8a7cb1b2e56dd1e262a0c63db79c3c1 (patch) | |
tree | 6a90c133ab7d125a5ea2fc7c2f5e4c6296ce4e0e /fs/f2fs/gc.c | |
parent | 7c4abcbeccdd286e7d71b3e8f9fefad84112e54c (diff) | |
download | linux-stable-43ced84ec8a7cb1b2e56dd1e262a0c63db79c3c1.tar.gz linux-stable-43ced84ec8a7cb1b2e56dd1e262a0c63db79c3c1.tar.bz2 linux-stable-43ced84ec8a7cb1b2e56dd1e262a0c63db79c3c1.zip |
f2fs: clean up foreground GC flow
This patch changes to check valid block number of one GCed section
directly instead of checking the number in all segments of section
one by one in order to clean up codes of foreground GC.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/gc.c')
-rw-r--r-- | fs/f2fs/gc.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 8f7fa326ce95..c1599b48859b 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -815,7 +815,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, struct blk_plug plug; unsigned int segno = start_segno; unsigned int end_segno = start_segno + sbi->segs_per_sec; - int seg_freed = 0; + int sec_freed = 0; unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ? SUM_TYPE_DATA : SUM_TYPE_NODE; @@ -871,22 +871,20 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, blk_finish_plug(&plug); - if (gc_type == FG_GC) { - while (start_segno < end_segno) - if (get_valid_blocks(sbi, start_segno++, 1) == 0) - seg_freed++; - } + if (gc_type == FG_GC && + get_valid_blocks(sbi, start_segno, sbi->segs_per_sec) == 0) + sec_freed = 1; stat_inc_call_count(sbi->stat_info); - return seg_freed; + return sec_freed; } int f2fs_gc(struct f2fs_sb_info *sbi, bool sync) { unsigned int segno; int gc_type = sync ? FG_GC : BG_GC; - int sec_freed = 0, seg_freed; + int sec_freed = 0; int ret = -EINVAL; struct cp_control cpc; struct gc_inode_list gc_list = { @@ -925,9 +923,8 @@ gc_more: goto stop; ret = 0; - seg_freed = do_garbage_collect(sbi, segno, &gc_list, gc_type); - - if (gc_type == FG_GC && seg_freed == sbi->segs_per_sec) + if (do_garbage_collect(sbi, segno, &gc_list, gc_type) && + gc_type == FG_GC) sec_freed++; if (gc_type == FG_GC) |