소스 검색

f2fs: skip new checkpoint when doing fstrim without fs change

This patch enables to do fstrim without checkpoint, if there is no fs
change.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Yunlei He 9 년 전
부모
커밋
58cce381fa
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      fs/f2fs/checkpoint.c

+ 11 - 0
fs/f2fs/checkpoint.c

@@ -1190,6 +1190,17 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
 
 	f2fs_flush_merged_bios(sbi);
 	f2fs_flush_merged_bios(sbi);
 
 
+	/* this is the case of multiple fstrims without any changes */
+	if (cpc->reason == CP_DISCARD && !is_sbi_flag_set(sbi, SBI_IS_DIRTY)) {
+		f2fs_bug_on(sbi, NM_I(sbi)->dirty_nat_cnt);
+		f2fs_bug_on(sbi, SIT_I(sbi)->dirty_sentries);
+		f2fs_bug_on(sbi, prefree_segments(sbi));
+		flush_sit_entries(sbi, cpc);
+		clear_prefree_segments(sbi, cpc);
+		unblock_operations(sbi);
+		goto out;
+	}
+
 	/*
 	/*
 	 * update checkpoint pack index
 	 * update checkpoint pack index
 	 * Increase the version number so that
 	 * Increase the version number so that