aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/f2fs/segment.c
diff options
context:
space:
mode:
authorYunlei He <heyunlei@huawei.com>2016-09-01 10:14:39 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2016-09-12 10:30:40 -0700
commited214a11830a12a83511eb32415e71f1a0760b8a (patch)
tree24a52160867a48bd15332f0babc7c247161785e0 /fs/f2fs/segment.c
parentf2fs: avoid page allocation for truncating partial inline_data (diff)
downloadwireguard-linux-ed214a11830a12a83511eb32415e71f1a0760b8a.tar.xz
wireguard-linux-ed214a11830a12a83511eb32415e71f1a0760b8a.zip
f2fs: forbid to do fstrim if fs has some error
This patch skip fstrim if sbi set SBI_NEED_FSCK flag Signed-off-by: Yunlei He <heyunlei@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r--fs/f2fs/segment.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index ff4b7238f36d..3ff462139436 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1353,6 +1353,12 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
if (end <= MAIN_BLKADDR(sbi))
goto out;
+ if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) {
+ f2fs_msg(sbi->sb, KERN_WARNING,
+ "Found FS corruption, run fsck to fix.");
+ goto out;
+ }
+
/* start/end segment number in main_area */
start_segno = (start <= MAIN_BLKADDR(sbi)) ? 0 : GET_SEGNO(sbi, start);
end_segno = (end >= MAX_BLKADDR(sbi)) ? MAIN_SEGS(sbi) - 1 :