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(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 5fc83771042d..8ef1449272b3 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -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);
--
2.25.1
On 01/13, Yangtao Li wrote:
> 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(-)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 5fc83771042d..8ef1449272b3 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -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;
It seems this changes the behavior?
> +
> 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);
> --
> 2.25.1