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

Herbert Xu herbert at gondor.apana.org.au
Fri Mar 14 22:40:54 PDT 2025


On Sat, Mar 15, 2025 at 01:08:21PM +0800, Zhihao Cheng wrote:
> 
> The crypto_acomp_alg_name() gets name from compr->cc(the name is initialized
> by compr->capi_name).
> I got the following messages after verifying:
> [  154.907048] UBIFS warning (ubi0:0 pid 110): ubifs_compress_req.isra.0
> [ubifs]: cannot compress 4096 bytes, compressor deflate, error -12, leave
> data uncompressed
> 
> The 'deflate' is zlib compressor's capi_name, but we expect it be 'zlib'
> here.

Sorry I overlooked this difference.  I will fold the following
patch into the series when I repost.

Thanks,

diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c
index 9973a2853de7..8d481c8338c3 100644
--- a/fs/ubifs/compress.c
+++ b/fs/ubifs/compress.c
@@ -70,7 +70,8 @@ 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)
+			      void *out_buf, int *out_len,
+			      const char *compr_name)
 {
 	struct crypto_wait wait;
 	int in_len = req->slen;
@@ -86,9 +87,7 @@ static int ubifs_compress_req(const struct ubifs_info *c,
 
 	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)),
-			   err);
+			   in_len, compr_name, err);
 	} else if (in_len - *out_len < UBIFS_MIN_COMPRESS_DIFF) {
 		/*
 		 * If the data compressed only slightly, it is better
@@ -138,7 +137,7 @@ void ubifs_compress(const struct ubifs_info *c, const void *in_buf,
 		ACOMP_REQUEST_ALLOC(req, compr->cc, GFP_NOFS | __GFP_NOWARN);
 
 		acomp_request_set_src_dma(req, in_buf, in_len);
-		err = ubifs_compress_req(c, req, out_buf, out_len);
+		err = ubifs_compress_req(c, req, out_buf, out_len, compr->name);
 	}
 
 	if (err)
@@ -190,7 +189,7 @@ void ubifs_compress_folio(const struct ubifs_info *c, struct folio *in_folio,
 		ACOMP_REQUEST_ALLOC(req, compr->cc, GFP_NOFS | __GFP_NOWARN);
 
 		acomp_request_set_src_folio(req, in_folio, in_offset, in_len);
-		err = ubifs_compress_req(c, req, out_buf, out_len);
+		err = ubifs_compress_req(c, req, out_buf, out_len, compr->name);
 	}
 
 	if (err)
@@ -206,7 +205,8 @@ void ubifs_compress_folio(const struct ubifs_info *c, struct folio *in_folio,
 
 static int ubifs_decompress_req(const struct ubifs_info *c,
 				struct acomp_req *req,
-				const void *in_buf, int in_len, int *out_len)
+				const void *in_buf, int in_len, int *out_len,
+				const char *compr_name)
 {
 	struct crypto_wait wait;
 	int err;
@@ -221,9 +221,7 @@ static int ubifs_decompress_req(const struct ubifs_info *c,
 
 	if (err)
 		ubifs_err(c, "cannot decompress %d bytes, compressor %s, error %d",
-			  in_len,
-			  crypto_acomp_alg_name(crypto_acomp_reqtfm(req)),
-			  err);
+			  in_len, compr_name, err);
 
 	acomp_request_free(req);
 
@@ -270,7 +268,8 @@ int ubifs_decompress(const struct ubifs_info *c, const void *in_buf,
 		ACOMP_REQUEST_ALLOC(req, compr->cc, GFP_NOFS | __GFP_NOWARN);
 
 		acomp_request_set_dst_dma(req, out_buf, *out_len);
-		return ubifs_decompress_req(c, req, in_buf, in_len, out_len);
+		return ubifs_decompress_req(c, req, in_buf, in_len, out_len,
+					    compr->name);
 	}
 }
 
@@ -318,7 +317,8 @@ int ubifs_decompress_folio(const struct ubifs_info *c, const void *in_buf,
 
 		acomp_request_set_dst_folio(req, out_folio, out_offset,
 					    *out_len);
-		return ubifs_decompress_req(c, req, in_buf, in_len, out_len);
+		return ubifs_decompress_req(c, req, in_buf, in_len, out_len,
+					    compr->name);
 	}
 }
 
-- 
Email: Herbert Xu <herbert at gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



More information about the linux-mtd mailing list