aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2016-08-19 11:13:46 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2016-08-29 21:31:08 -0400
commit43ced84ec8a7cb1b2e56dd1e262a0c63db79c3c1 (patch)
tree6a90c133ab7d125a5ea2fc7c2f5e4c6296ce4e0e
parent7c4abcbeccdd286e7d71b3e8f9fefad84112e54c (diff)
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>
-rw-r--r--fs/f2fs/gc.c19
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,
815 struct blk_plug plug; 815 struct blk_plug plug;
816 unsigned int segno = start_segno; 816 unsigned int segno = start_segno;
817 unsigned int end_segno = start_segno + sbi->segs_per_sec; 817 unsigned int end_segno = start_segno + sbi->segs_per_sec;
818 int seg_freed = 0; 818 int sec_freed = 0;
819 unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ? 819 unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ?
820 SUM_TYPE_DATA : SUM_TYPE_NODE; 820 SUM_TYPE_DATA : SUM_TYPE_NODE;
821 821
@@ -871,22 +871,20 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
871 871
872 blk_finish_plug(&plug); 872 blk_finish_plug(&plug);
873 873
874 if (gc_type == FG_GC) { 874 if (gc_type == FG_GC &&
875 while (start_segno < end_segno) 875 get_valid_blocks(sbi, start_segno, sbi->segs_per_sec) == 0)
876 if (get_valid_blocks(sbi, start_segno++, 1) == 0) 876 sec_freed = 1;
877 seg_freed++;
878 }
879 877
880 stat_inc_call_count(sbi->stat_info); 878 stat_inc_call_count(sbi->stat_info);
881 879
882 return seg_freed; 880 return sec_freed;
883} 881}
884 882
885int f2fs_gc(struct f2fs_sb_info *sbi, bool sync) 883int f2fs_gc(struct f2fs_sb_info *sbi, bool sync)
886{ 884{
887 unsigned int segno; 885 unsigned int segno;
888 int gc_type = sync ? FG_GC : BG_GC; 886 int gc_type = sync ? FG_GC : BG_GC;
889 int sec_freed = 0, seg_freed; 887 int sec_freed = 0;
890 int ret = -EINVAL; 888 int ret = -EINVAL;
891 struct cp_control cpc; 889 struct cp_control cpc;
892 struct gc_inode_list gc_list = { 890 struct gc_inode_list gc_list = {
@@ -925,9 +923,8 @@ gc_more:
925 goto stop; 923 goto stop;
926 ret = 0; 924 ret = 0;
927 925
928 seg_freed = do_garbage_collect(sbi, segno, &gc_list, gc_type); 926 if (do_garbage_collect(sbi, segno, &gc_list, gc_type) &&
929 927 gc_type == FG_GC)
930 if (gc_type == FG_GC && seg_freed == sbi->segs_per_sec)
931 sec_freed++; 928 sec_freed++;
932 929
933 if (gc_type == FG_GC) 930 if (gc_type == FG_GC)