diff options
author | Chao Yu <chao@kernel.org> | 2021-08-30 08:35:33 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2021-08-30 10:12:50 -0700 |
commit | f7db8dd6981e0d94e5e35b45c1d288c94357de52 (patch) | |
tree | c3a2b64b735b6cc66fe4732655d7e4d03d352d75 /fs/f2fs | |
parent | dddd3d65293a52c2c3850c19b1e5115712e534d8 (diff) | |
download | linux-stable-f7db8dd6981e0d94e5e35b45c1d288c94357de52.tar.gz linux-stable-f7db8dd6981e0d94e5e35b45c1d288c94357de52.tar.bz2 linux-stable-f7db8dd6981e0d94e5e35b45c1d288c94357de52.zip |
f2fs: enable realtime discard iff device supports discard
Let's only enable realtime discard if and only if device supports
discard functionality.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/super.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 703fe8991838..a29e6714c610 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -661,10 +661,14 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) return -EINVAL; break; case Opt_discard: + if (!f2fs_hw_support_discard(sbi)) { + f2fs_warn(sbi, "device does not support discard"); + break; + } set_opt(sbi, DISCARD); break; case Opt_nodiscard: - if (f2fs_sb_has_blkzoned(sbi)) { + if (f2fs_hw_should_discard(sbi)) { f2fs_warn(sbi, "discard is required for zoned block devices"); return -EINVAL; } @@ -2001,7 +2005,8 @@ static void default_options(struct f2fs_sb_info *sbi) F2FS_OPTION(sbi).unusable_cap = 0; sbi->sb->s_flags |= SB_LAZYTIME; set_opt(sbi, FLUSH_MERGE); - set_opt(sbi, DISCARD); + if (f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi)) + set_opt(sbi, DISCARD); if (f2fs_sb_has_blkzoned(sbi)) { F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS; F2FS_OPTION(sbi).discard_unit = DISCARD_UNIT_SECTION; |