f2fs: add compression feature check for all compress mount opt
PATCH 1/1 f2fs: add compression feature check for all compress mount opt
Opt_compress_chksum, Opt_compress_mode and Opt_compress_cache lack the necessary check to see if the image supports compression, let's add it.
Signed-off-by Yangtao Li <[email protected]>
--- fs/f2fs/super.c | 55 +++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 27 deletions(-)
fs/f2fs/super.c +28 -27
@@ -89,7 +89,7 @@ static struct shrinker f2fs_shrinker_info = { .seeks = DEFAULT_SEEKS, }; -enum { +enum f2fs_mount_opt { Opt_gc_background, Opt_disable_roll_forward, Opt_norecovery,
@@ -655,6 +655,30 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)#endif #endif +static bool f2fs_mount_opt_need_skip (struct f2fs_sb_info *sbi,enum f2fs_mount_opt opt) +{ +switch (opt) { +case Opt_compress_algorithm: +case Opt_compress_log_size: +case Opt_compress_extension: +case Opt_nocompress_extension: +case Opt_compress_chksum: +case Opt_compress_mode: +case Opt_compress_cache: +#ifdef CONFIG_F2FS_FS_COMPRESSION +if (f2fs_sb_has_compression (sbi)) +return false; + +f2fs_info (sbi,"Image doesn't support compression" ); +#else +f2fs_info (sbi,"compression options not supported" ); +#endif +return true; +default : +return false; + } +} +static int parse_options (struct super_block *sb,char *options,bool is_remount) {struct f2fs_sb_info *sbi =F2FS_SB (sb);
@@ -685,6 +709,9 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) args[0 ].to = args[0 ].from =NULL ; token =match_token (p, f2fs_tokens, args); +if (f2fs_mount_opt_need_skip (sbi, token)) +continue ; +switch (token) {case Opt_gc_background: name =match_strdup (&args[0 ]);
@@ -1068,10 +1095,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ;#ifdef CONFIG_F2FS_FS_COMPRESSION case Opt_compress_algorithm: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - } name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ;
@@ -1122,10 +1145,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)kfree (name);break ;case Opt_compress_log_size: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - }if (args->from &&match_int (args, &arg))return -EINVAL ; if (arg < MIN_COMPRESS_LOG_SIZE ||
@@ -1137,10 +1156,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)F2FS_OPTION (sbi).compress_log_size = arg;break ;case Opt_compress_extension: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - } name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ;
@@ -1161,10 +1176,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)kfree (name);break ;case Opt_nocompress_extension: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - } name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ;
@@ -1204,16 +1215,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_compress_cache:set_opt (sbi,COMPRESS_CACHE );break ; -#else -case Opt_compress_algorithm: -case Opt_compress_log_size: -case Opt_compress_extension: -case Opt_nocompress_extension: -case Opt_compress_chksum: -case Opt_compress_mode: -case Opt_compress_cache: -f2fs_info (sbi,"compression options not supported" ); -break ;#endif case Opt_atgc:set_opt (sbi,ATGC );
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 54 lines · Yangtao Li
Opt_compress_chksum,Opt_compress_modeandOpt_compress_cachelack the necessary check to see if the image supports compression, let's add it.Signed-off-by Yangtao Li <[email protected]>--- fs/f2fs/super.c | 55 +++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 27 deletions(-)fs/f2fs/super.c +25
-1@@ -89,7 +89,7 @@ static struct shrinker f2fs_shrinker_info = { .seeks = DEFAULT_SEEKS, }; -enum { +enum f2fs_mount_opt { Opt_gc_background, Opt_disable_roll_forward, Opt_norecovery,@@ -655,6 +655,30 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)#endif #endif +static bool f2fs_mount_opt_need_skip (struct f2fs_sb_info *sbi,enum f2fs_mount_opt opt) +{ +switch (opt) { +case Opt_compress_algorithm: +case Opt_compress_log_size: +case Opt_compress_extension: +case Opt_nocompress_extension: +case Opt_compress_chksum: +case Opt_compress_mode: +case Opt_compress_cache: +#ifdef CONFIG_F2FS_FS_COMPRESSION +if (f2fs_sb_has_compression (sbi)) +return false; + +f2fs_info (sbi,"Image doesn't support compression" ); +#else +f2fs_info (sbi,"compression options not supported" ); +#endif +return true; +default : +return false; + } +} +static int parse_options (struct super_block *sb,char *options,bool is_remount) {struct f2fs_sb_info *sbi =F2FS_SB (sb);
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 713
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -685,6 +709,9 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) args[0 ].to = args[0 ].from =NULL ; token =match_token (p, f2fs_tokens, args); +if (f2fs_mount_opt_need_skip (sbi, token)) +continue ;
It seems this changes the behavior?
Quoted 67 lines
fs/f2fs/super.c +1
-26+switch (token) {case Opt_gc_background: name =match_strdup (&args[0 ]);@@ -1068,10 +1095,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ;#ifdef CONFIG_F2FS_FS_COMPRESSION case Opt_compress_algorithm: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - } name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ;@@ -1122,10 +1145,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)kfree (name);break ;case Opt_compress_log_size: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - }if (args->from &&match_int (args, &arg))return -EINVAL ; if (arg < MIN_COMPRESS_LOG_SIZE ||@@ -1137,10 +1156,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)F2FS_OPTION (sbi).compress_log_size = arg;break ;case Opt_compress_extension: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - } name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ;@@ -1161,10 +1176,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)kfree (name);break ;case Opt_nocompress_extension: -if (!f2fs_sb_has_compression (sbi)) { -f2fs_info (sbi,"Image doesn't support compression" ); -break ; - } name =match_strdup (&args[0 ]);if (!name)return -ENOMEM ;@@ -1204,16 +1215,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_compress_cache:set_opt (sbi,COMPRESS_CACHE );break ; -#else -case Opt_compress_algorithm: -case Opt_compress_log_size: -case Opt_compress_extension: -case Opt_nocompress_extension: -case Opt_compress_chksum: -case Opt_compress_mode: -case Opt_compress_cache: -f2fs_info (sbi,"compression options not supported" ); -break ;#endif case Opt_atgc:set_opt (sbi,ATGC );Signature · 1 line
2.25.1