Re: [v4 PATCH 10/13] ubifs: Use crypto_acomp interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



在 2025/3/14 20:22, Herbert Xu 写道:
Replace the legacy crypto compression interface with the new acomp
interface.

Remove the compression mutexes and the overallocation for memory
(the offender LZO has been fixed).

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
---
  fs/ubifs/compress.c | 116 ++++++++++++++++++++++++++++----------------
  fs/ubifs/journal.c  |   2 +-
  fs/ubifs/ubifs.h    |  15 +-----
  3 files changed, 77 insertions(+), 56 deletions(-)

diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c
index 0b48cbab8a3d..9046e796876d 100644
--- a/fs/ubifs/compress.c
+++ b/fs/ubifs/compress.c
@@ -15,7 +15,7 @@
   * decompression.
   */
-#include <linux/crypto.h>
+#include <crypto/acompress.h>
  #include "ubifs.h"
/* Fake description object for the "none" compressor */
@@ -26,11 +26,8 @@ static struct ubifs_compressor none_compr = {
  };
#ifdef CONFIG_UBIFS_FS_LZO
-static DEFINE_MUTEX(lzo_mutex);
-
  static struct ubifs_compressor lzo_compr = {
  	.compr_type = UBIFS_COMPR_LZO,
-	.comp_mutex = &lzo_mutex,
  	.name = "lzo",
  	.capi_name = "lzo",
  };
@@ -42,13 +39,8 @@ static struct ubifs_compressor lzo_compr = {
  #endif
#ifdef CONFIG_UBIFS_FS_ZLIB
-static DEFINE_MUTEX(deflate_mutex);
-static DEFINE_MUTEX(inflate_mutex);
-
  static struct ubifs_compressor zlib_compr = {
  	.compr_type = UBIFS_COMPR_ZLIB,
-	.comp_mutex = &deflate_mutex,
-	.decomp_mutex = &inflate_mutex,
  	.name = "zlib",
  	.capi_name = "deflate",
  };
@@ -60,13 +52,8 @@ static struct ubifs_compressor zlib_compr = {
  #endif
#ifdef CONFIG_UBIFS_FS_ZSTD
-static DEFINE_MUTEX(zstd_enc_mutex);
-static DEFINE_MUTEX(zstd_dec_mutex);
-
  static struct ubifs_compressor zstd_compr = {
  	.compr_type = UBIFS_COMPR_ZSTD,
-	.comp_mutex = &zstd_enc_mutex,
-	.decomp_mutex = &zstd_dec_mutex,
  	.name = "zstd",
  	.capi_name = "zstd",
  };
@@ -80,6 +67,40 @@ static struct ubifs_compressor zstd_compr = {
  /* All UBIFS compressors */
  struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
+static int ubifs_compress_req(const struct ubifs_info *c,
+			      struct acomp_req *req,
+			      void *out_buf, int *out_len)
+{
+	struct crypto_wait wait;
+	int in_len = req->slen;
+	int err;
+
+	crypto_init_wait(&wait);
+	acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+				   crypto_req_done, &wait);
+	acomp_request_set_dst_dma(req, out_buf, *out_len);
+	err = crypto_acomp_compress(req);
+	err = crypto_wait_req(err, &wait);
+	*out_len = req->dlen;
+
+	if (unlikely(err)) {
+		ubifs_warn(c, "cannot compress %d bytes, compressor %s, error %d, leave data uncompressed",
+			   in_len,
+			   crypto_acomp_alg_name(crypto_acomp_reqtfm(req)),

We get capi_name by 'crypto_acomp_alg_name(crypto_acomp_reqtfm(req))', not compr->name.

There are conflicts in patch 2 on the latest mainline version, can you rebase this series so I can do some tests for UBIFS.




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux