]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
f2fs: add a new function get_ssr_cost
authorYunlei He <heyunlei@huawei.com>
Wed, 17 May 2017 09:22:51 +0000 (17:22 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 24 May 2017 04:07:17 +0000 (21:07 -0700)
This patch add a new method get_ssr_cost to select
SSR segment more accurately.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/gc.c

index 14c71ac760621ef9928b3d2573c8593fbf2ee259..81392970fb2da6a9b528e06e937f204177b7d91f 100644 (file)
@@ -258,11 +258,20 @@ static unsigned int get_greedy_cost(struct f2fs_sb_info *sbi,
                                valid_blocks * 2 : valid_blocks;
 }
 
+static unsigned int get_ssr_cost(struct f2fs_sb_info *sbi,
+                                               unsigned int segno)
+{
+       struct seg_entry *se = get_seg_entry(sbi, segno);
+
+       return se->ckpt_valid_blocks > se->valid_blocks ?
+                               se->ckpt_valid_blocks : se->valid_blocks;
+}
+
 static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi,
                        unsigned int segno, struct victim_sel_policy *p)
 {
        if (p->alloc_mode == SSR)
-               return get_seg_entry(sbi, segno)->ckpt_valid_blocks;
+               return get_ssr_cost(sbi, segno);
 
        /* alloc_mode == LFS */
        if (p->gc_mode == GC_GREEDY)