linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: add compression feature check for all compress mount opt
@ 2023-01-12 20:10 Yangtao Li via Linux-f2fs-devel
  2023-01-19  2:15 ` Jaegeuk Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Yangtao Li via Linux-f2fs-devel @ 2023-01-12 20:10 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Yangtao Li, linux-kernel, linux-f2fs-devel

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 <frank.li@vivo.com>
---
 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



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: add compression feature check for all compress mount opt
  2023-01-12 20:10 [f2fs-dev] [PATCH] f2fs: add compression feature check for all compress mount opt Yangtao Li via Linux-f2fs-devel
@ 2023-01-19  2:15 ` Jaegeuk Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2023-01-19  2:15 UTC (permalink / raw)
  To: Yangtao Li; +Cc: linux-kernel, linux-f2fs-devel

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 <frank.li@vivo.com>
> ---
>  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


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-19  2:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12 20:10 [f2fs-dev] [PATCH] f2fs: add compression feature check for all compress mount opt Yangtao Li via Linux-f2fs-devel
2023-01-19  2:15 ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).