Commit f7db8dd6 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

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: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent dddd3d65
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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,6 +2005,7 @@ 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);
	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;