Skip to content

Commit 2880f47

Browse files
weichao-guoJaegeuk Kim
authored andcommitted
f2fs: skip GC if possible when checkpoint disabling
If the number of unusable blocks is not larger than unusable capacity, we can skip GC when checkpoint disabling. Signed-off-by: Weichao Guo <guoweichao@oppo.com> Signed-off-by: Chao Yu <chao@kernel.org> [Jaegeuk Kim: Fix missing gc_mode assignment] Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 7141912 commit 2880f47

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/f2fs/super.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
20582058
{
20592059
unsigned int s_flags = sbi->sb->s_flags;
20602060
struct cp_control cpc;
2061-
unsigned int gc_mode;
2061+
unsigned int gc_mode = sbi->gc_mode;
20622062
int err = 0;
20632063
int ret;
20642064
block_t unusable;
@@ -2069,9 +2069,13 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
20692069
}
20702070
sbi->sb->s_flags |= SB_ACTIVE;
20712071

2072+
/* check if we need more GC first */
2073+
unusable = f2fs_get_unusable_blocks(sbi);
2074+
if (!f2fs_disable_cp_again(sbi, unusable))
2075+
goto skip_gc;
2076+
20722077
f2fs_update_time(sbi, DISABLE_TIME);
20732078

2074-
gc_mode = sbi->gc_mode;
20752079
sbi->gc_mode = GC_URGENT_HIGH;
20762080

20772081
while (!f2fs_time_over(sbi, DISABLE_TIME)) {
@@ -2097,6 +2101,7 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
20972101
goto restore_flag;
20982102
}
20992103

2104+
skip_gc:
21002105
f2fs_down_write(&sbi->gc_lock);
21012106
cpc.reason = CP_PAUSE;
21022107
set_sbi_flag(sbi, SBI_CP_DISABLED);

0 commit comments

Comments
 (0)