Skip to content

Commit bab2a03

Browse files
Jaegeuk Kimpundiramit
authored andcommitted
f2fs: avoid needless checkpoint in f2fs_trim_fs
commit 0333ad4e4f49e14217256e1db1134a70cf60b2de upstream. The f2fs_trim_fs() doesn't need to do checkpoint if there are newly allocated data blocks only which didn't change the critical checkpoint data such as nat and sit entries. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 551836d commit bab2a03

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

fs/f2fs/checkpoint.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,14 +1249,15 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
12491249
f2fs_flush_merged_bios(sbi);
12501250

12511251
/* this is the case of multiple fstrims without any changes */
1252-
if (cpc->reason == CP_DISCARD && !is_sbi_flag_set(sbi, SBI_IS_DIRTY)) {
1253-
f2fs_bug_on(sbi, NM_I(sbi)->dirty_nat_cnt);
1254-
f2fs_bug_on(sbi, SIT_I(sbi)->dirty_sentries);
1255-
f2fs_bug_on(sbi, prefree_segments(sbi));
1256-
flush_sit_entries(sbi, cpc);
1257-
clear_prefree_segments(sbi, cpc);
1258-
unblock_operations(sbi);
1259-
goto out;
1252+
if (cpc->reason == CP_DISCARD) {
1253+
if (NM_I(sbi)->dirty_nat_cnt == 0 &&
1254+
SIT_I(sbi)->dirty_sentries == 0 &&
1255+
prefree_segments(sbi) == 0) {
1256+
flush_sit_entries(sbi, cpc);
1257+
clear_prefree_segments(sbi, cpc);
1258+
unblock_operations(sbi);
1259+
goto out;
1260+
}
12601261
}
12611262

12621263
/*

0 commit comments

Comments
 (0)