aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunlei He <heyunlei@huawei.com>2016-08-18 21:01:19 +0800
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:33:58 +0200
commitbfa38445aa54de1548d0cb781ec1aebc5abda78e (patch)
tree9a7b7eeaa415467b054f2aef87f0ef83f0c3004c
parent2c544a5a4257ea28abfdbc954cec93dd7d4472bd (diff)
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>
-rw-r--r--fs/f2fs/checkpoint.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 5a3ee5e56..d4b6c1478 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1189,6 +1189,17 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
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
* Increase the version number so that