When turning to FG_GC from BG_GC, we need to write checkpoint in 2 cases:
* a) BG_GC have made some progress, e.g.: some prefree segments.
* b) There is no victim and no prefree segment.

For case a), previously, we also check if there is a dirty segment for
infering blocks moving in last BG_GC. But dirty segments do not always
indicate that, BG_GC may just start and do not move any blocks at all.
Futhermore, skipping checkpoint if there are some dirty segments but no
prefree segments is OK.

Signed-off-by: Weichao Guo <guoweic...@huawei.com>
---
 fs/f2fs/gc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 6c996e3..30d206a 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -958,7 +958,12 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, bool 
background)
                 * enough free sections, we should flush dent/node blocks and do
                 * garbage collections.
                 */
-               ret = write_checkpoint(sbi, &cpc);
+               if (prefree_segments(sbi))
+                       ret = write_checkpoint(sbi, &cpc);
+               else if (!__get_victim(sbi, &segno, gc_type) {
+                       segno = NULL_SEGNO;
+                       ret = write_checkpoint(sbi, &cpc);
+               }
                if (ret)
                        goto stop;
        } else if (gc_type == BG_GC && !background) {
-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to