All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] erofs: get rid of name from struct z_erofs_decompressor
@ 2023-04-26  4:10 ` Yue Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2023-04-26  4:10 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: jefflexu, huyue2, linux-kernel, zhangwen

From: Yue Hu <huyue2@coolpad.com>

There are no users of the name and we can get this via ->alg if needed.
Also, move struct z_erofs_decompressor into decompressor.c which is the
only one to use it.

Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 fs/erofs/compress.h     | 6 ------
 fs/erofs/decompressor.c | 9 +++++----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/fs/erofs/compress.h b/fs/erofs/compress.h
index 26fa170090b8..d161683bda03 100644
--- a/fs/erofs/compress.h
+++ b/fs/erofs/compress.h
@@ -20,12 +20,6 @@ struct z_erofs_decompress_req {
 	bool inplace_io, partial_decoding, fillgaps;
 };
 
-struct z_erofs_decompressor {
-	int (*decompress)(struct z_erofs_decompress_req *rq,
-			  struct page **pagepool);
-	char *name;
-};
-
 /* some special page->private (unsigned long, see below) */
 #define Z_EROFS_SHORTLIVED_PAGE		(-1UL << 2)
 #define Z_EROFS_PREALLOCATED_PAGE	(-2UL << 2)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 7021e2cf6146..f416ebd6f0dc 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -363,23 +363,24 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
 	return 0;
 }
 
+struct z_erofs_decompressor {
+	int (*decompress)(struct z_erofs_decompress_req *rq,
+			  struct page **pagepool);
+};
+
 static struct z_erofs_decompressor decompressors[] = {
 	[Z_EROFS_COMPRESSION_SHIFTED] = {
 		.decompress = z_erofs_transform_plain,
-		.name = "shifted"
 	},
 	[Z_EROFS_COMPRESSION_INTERLACED] = {
 		.decompress = z_erofs_transform_plain,
-		.name = "interlaced"
 	},
 	[Z_EROFS_COMPRESSION_LZ4] = {
 		.decompress = z_erofs_lz4_decompress,
-		.name = "lz4"
 	},
 #ifdef CONFIG_EROFS_FS_ZIP_LZMA
 	[Z_EROFS_COMPRESSION_LZMA] = {
 		.decompress = z_erofs_lzma_decompress,
-		.name = "lzma"
 	},
 #endif
 };
-- 
2.17.1


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

* [PATCH 1/2] erofs: get rid of name from struct z_erofs_decompressor
@ 2023-04-26  4:10 ` Yue Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2023-04-26  4:10 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel, zhangwen

From: Yue Hu <huyue2@coolpad.com>

There are no users of the name and we can get this via ->alg if needed.
Also, move struct z_erofs_decompressor into decompressor.c which is the
only one to use it.

Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 fs/erofs/compress.h     | 6 ------
 fs/erofs/decompressor.c | 9 +++++----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/fs/erofs/compress.h b/fs/erofs/compress.h
index 26fa170090b8..d161683bda03 100644
--- a/fs/erofs/compress.h
+++ b/fs/erofs/compress.h
@@ -20,12 +20,6 @@ struct z_erofs_decompress_req {
 	bool inplace_io, partial_decoding, fillgaps;
 };
 
-struct z_erofs_decompressor {
-	int (*decompress)(struct z_erofs_decompress_req *rq,
-			  struct page **pagepool);
-	char *name;
-};
-
 /* some special page->private (unsigned long, see below) */
 #define Z_EROFS_SHORTLIVED_PAGE		(-1UL << 2)
 #define Z_EROFS_PREALLOCATED_PAGE	(-2UL << 2)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 7021e2cf6146..f416ebd6f0dc 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -363,23 +363,24 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
 	return 0;
 }
 
+struct z_erofs_decompressor {
+	int (*decompress)(struct z_erofs_decompress_req *rq,
+			  struct page **pagepool);
+};
+
 static struct z_erofs_decompressor decompressors[] = {
 	[Z_EROFS_COMPRESSION_SHIFTED] = {
 		.decompress = z_erofs_transform_plain,
-		.name = "shifted"
 	},
 	[Z_EROFS_COMPRESSION_INTERLACED] = {
 		.decompress = z_erofs_transform_plain,
-		.name = "interlaced"
 	},
 	[Z_EROFS_COMPRESSION_LZ4] = {
 		.decompress = z_erofs_lz4_decompress,
-		.name = "lz4"
 	},
 #ifdef CONFIG_EROFS_FS_ZIP_LZMA
 	[Z_EROFS_COMPRESSION_LZMA] = {
 		.decompress = z_erofs_lzma_decompress,
-		.name = "lzma"
 	},
 #endif
 };
-- 
2.17.1


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

* [PATCH 2/2] erofs: replace global decompressors[] with stack memory
  2023-04-26  4:10 ` Yue Hu
@ 2023-04-26  4:10   ` Yue Hu
  -1 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2023-04-26  4:10 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: jefflexu, huyue2, linux-kernel, zhangwen

From: Yue Hu <huyue2@coolpad.com>

Note that only z_erofs_decompress() is using the decompressors[], so no
need to keep it as global resource, just use local one instead.

Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 fs/erofs/decompressor.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index f416ebd6f0dc..91d91bdd068f 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -368,25 +368,24 @@ struct z_erofs_decompressor {
 			  struct page **pagepool);
 };
 
-static struct z_erofs_decompressor decompressors[] = {
-	[Z_EROFS_COMPRESSION_SHIFTED] = {
-		.decompress = z_erofs_transform_plain,
-	},
-	[Z_EROFS_COMPRESSION_INTERLACED] = {
-		.decompress = z_erofs_transform_plain,
-	},
-	[Z_EROFS_COMPRESSION_LZ4] = {
-		.decompress = z_erofs_lz4_decompress,
-	},
-#ifdef CONFIG_EROFS_FS_ZIP_LZMA
-	[Z_EROFS_COMPRESSION_LZMA] = {
-		.decompress = z_erofs_lzma_decompress,
-	},
-#endif
-};
-
 int z_erofs_decompress(struct z_erofs_decompress_req *rq,
 		       struct page **pagepool)
 {
+	struct z_erofs_decompressor decompressors[] = {
+		[Z_EROFS_COMPRESSION_SHIFTED] = {
+			.decompress = z_erofs_transform_plain,
+		},
+		[Z_EROFS_COMPRESSION_INTERLACED] = {
+			.decompress = z_erofs_transform_plain,
+		},
+		[Z_EROFS_COMPRESSION_LZ4] = {
+			.decompress = z_erofs_lz4_decompress,
+		},
+#ifdef CONFIG_EROFS_FS_ZIP_LZMA
+		[Z_EROFS_COMPRESSION_LZMA] = {
+			.decompress = z_erofs_lzma_decompress,
+		},
+#endif
+	};
 	return decompressors[rq->alg].decompress(rq, pagepool);
 }
-- 
2.17.1


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

* [PATCH 2/2] erofs: replace global decompressors[] with stack memory
@ 2023-04-26  4:10   ` Yue Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2023-04-26  4:10 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel, zhangwen

From: Yue Hu <huyue2@coolpad.com>

Note that only z_erofs_decompress() is using the decompressors[], so no
need to keep it as global resource, just use local one instead.

Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 fs/erofs/decompressor.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index f416ebd6f0dc..91d91bdd068f 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -368,25 +368,24 @@ struct z_erofs_decompressor {
 			  struct page **pagepool);
 };
 
-static struct z_erofs_decompressor decompressors[] = {
-	[Z_EROFS_COMPRESSION_SHIFTED] = {
-		.decompress = z_erofs_transform_plain,
-	},
-	[Z_EROFS_COMPRESSION_INTERLACED] = {
-		.decompress = z_erofs_transform_plain,
-	},
-	[Z_EROFS_COMPRESSION_LZ4] = {
-		.decompress = z_erofs_lz4_decompress,
-	},
-#ifdef CONFIG_EROFS_FS_ZIP_LZMA
-	[Z_EROFS_COMPRESSION_LZMA] = {
-		.decompress = z_erofs_lzma_decompress,
-	},
-#endif
-};
-
 int z_erofs_decompress(struct z_erofs_decompress_req *rq,
 		       struct page **pagepool)
 {
+	struct z_erofs_decompressor decompressors[] = {
+		[Z_EROFS_COMPRESSION_SHIFTED] = {
+			.decompress = z_erofs_transform_plain,
+		},
+		[Z_EROFS_COMPRESSION_INTERLACED] = {
+			.decompress = z_erofs_transform_plain,
+		},
+		[Z_EROFS_COMPRESSION_LZ4] = {
+			.decompress = z_erofs_lz4_decompress,
+		},
+#ifdef CONFIG_EROFS_FS_ZIP_LZMA
+		[Z_EROFS_COMPRESSION_LZMA] = {
+			.decompress = z_erofs_lzma_decompress,
+		},
+#endif
+	};
 	return decompressors[rq->alg].decompress(rq, pagepool);
 }
-- 
2.17.1


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

* Re: [PATCH 1/2] erofs: get rid of name from struct z_erofs_decompressor
  2023-04-26  4:10 ` Yue Hu
@ 2023-04-26  6:08   ` Gao Xiang
  -1 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2023-04-26  6:08 UTC (permalink / raw)
  To: Yue Hu, xiang, chao, linux-erofs; +Cc: jefflexu, huyue2, linux-kernel, zhangwen



On 2023/4/26 12:10, Yue Hu wrote:
> From: Yue Hu <huyue2@coolpad.com>
> 
> There are no users of the name and we can get this via ->alg if needed.
> Also, move struct z_erofs_decompressor into decompressor.c which is the
> only one to use it.
> 
> Signed-off-by: Yue Hu <huyue2@coolpad.com>

I'd like to avoid z_erofs_decompress() function instead honestly.
name strings might be useful if users would like to get runtime
supported algorithms.

Thanks,
Gao Xiang

> ---
>   fs/erofs/compress.h     | 6 ------
>   fs/erofs/decompressor.c | 9 +++++----
>   2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/erofs/compress.h b/fs/erofs/compress.h
> index 26fa170090b8..d161683bda03 100644
> --- a/fs/erofs/compress.h
> +++ b/fs/erofs/compress.h
> @@ -20,12 +20,6 @@ struct z_erofs_decompress_req {
>   	bool inplace_io, partial_decoding, fillgaps;
>   };
>   
> -struct z_erofs_decompressor {
> -	int (*decompress)(struct z_erofs_decompress_req *rq,
> -			  struct page **pagepool);
> -	char *name;
> -};
> -
>   /* some special page->private (unsigned long, see below) */
>   #define Z_EROFS_SHORTLIVED_PAGE		(-1UL << 2)
>   #define Z_EROFS_PREALLOCATED_PAGE	(-2UL << 2)
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index 7021e2cf6146..f416ebd6f0dc 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -363,23 +363,24 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
>   	return 0;
>   }
>   
> +struct z_erofs_decompressor {
> +	int (*decompress)(struct z_erofs_decompress_req *rq,
> +			  struct page **pagepool);
> +};
> +
>   static struct z_erofs_decompressor decompressors[] = {
>   	[Z_EROFS_COMPRESSION_SHIFTED] = {
>   		.decompress = z_erofs_transform_plain,
> -		.name = "shifted"
>   	},
>   	[Z_EROFS_COMPRESSION_INTERLACED] = {
>   		.decompress = z_erofs_transform_plain,
> -		.name = "interlaced"
>   	},
>   	[Z_EROFS_COMPRESSION_LZ4] = {
>   		.decompress = z_erofs_lz4_decompress,
> -		.name = "lz4"
>   	},
>   #ifdef CONFIG_EROFS_FS_ZIP_LZMA
>   	[Z_EROFS_COMPRESSION_LZMA] = {
>   		.decompress = z_erofs_lzma_decompress,
> -		.name = "lzma"
>   	},
>   #endif
>   };

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

* Re: [PATCH 1/2] erofs: get rid of name from struct z_erofs_decompressor
@ 2023-04-26  6:08   ` Gao Xiang
  0 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2023-04-26  6:08 UTC (permalink / raw)
  To: Yue Hu, xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel, zhangwen



On 2023/4/26 12:10, Yue Hu wrote:
> From: Yue Hu <huyue2@coolpad.com>
> 
> There are no users of the name and we can get this via ->alg if needed.
> Also, move struct z_erofs_decompressor into decompressor.c which is the
> only one to use it.
> 
> Signed-off-by: Yue Hu <huyue2@coolpad.com>

I'd like to avoid z_erofs_decompress() function instead honestly.
name strings might be useful if users would like to get runtime
supported algorithms.

Thanks,
Gao Xiang

> ---
>   fs/erofs/compress.h     | 6 ------
>   fs/erofs/decompressor.c | 9 +++++----
>   2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/erofs/compress.h b/fs/erofs/compress.h
> index 26fa170090b8..d161683bda03 100644
> --- a/fs/erofs/compress.h
> +++ b/fs/erofs/compress.h
> @@ -20,12 +20,6 @@ struct z_erofs_decompress_req {
>   	bool inplace_io, partial_decoding, fillgaps;
>   };
>   
> -struct z_erofs_decompressor {
> -	int (*decompress)(struct z_erofs_decompress_req *rq,
> -			  struct page **pagepool);
> -	char *name;
> -};
> -
>   /* some special page->private (unsigned long, see below) */
>   #define Z_EROFS_SHORTLIVED_PAGE		(-1UL << 2)
>   #define Z_EROFS_PREALLOCATED_PAGE	(-2UL << 2)
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index 7021e2cf6146..f416ebd6f0dc 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -363,23 +363,24 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
>   	return 0;
>   }
>   
> +struct z_erofs_decompressor {
> +	int (*decompress)(struct z_erofs_decompress_req *rq,
> +			  struct page **pagepool);
> +};
> +
>   static struct z_erofs_decompressor decompressors[] = {
>   	[Z_EROFS_COMPRESSION_SHIFTED] = {
>   		.decompress = z_erofs_transform_plain,
> -		.name = "shifted"
>   	},
>   	[Z_EROFS_COMPRESSION_INTERLACED] = {
>   		.decompress = z_erofs_transform_plain,
> -		.name = "interlaced"
>   	},
>   	[Z_EROFS_COMPRESSION_LZ4] = {
>   		.decompress = z_erofs_lz4_decompress,
> -		.name = "lz4"
>   	},
>   #ifdef CONFIG_EROFS_FS_ZIP_LZMA
>   	[Z_EROFS_COMPRESSION_LZMA] = {
>   		.decompress = z_erofs_lzma_decompress,
> -		.name = "lzma"
>   	},
>   #endif
>   };

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

end of thread, other threads:[~2023-04-26  6:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-26  4:10 [PATCH 1/2] erofs: get rid of name from struct z_erofs_decompressor Yue Hu
2023-04-26  4:10 ` Yue Hu
2023-04-26  4:10 ` [PATCH 2/2] erofs: replace global decompressors[] with stack memory Yue Hu
2023-04-26  4:10   ` Yue Hu
2023-04-26  6:08 ` [PATCH 1/2] erofs: get rid of name from struct z_erofs_decompressor Gao Xiang
2023-04-26  6:08   ` Gao Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.