Re: [PATCH 1/1] lz4: Implement lz4 with dynamic offset length.

From: Sergey Senozhatsky
Date: Wed Mar 21 2018 - 03:50:04 EST


On (03/21/18 10:10), Maninder Singh wrote:
[..]
> +static struct crypto_alg alg_lz4_dyn = {
> + .cra_name = "lz4_dyn",
> + .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
> + .cra_ctxsize = sizeof(struct lz4_ctx),
> + .cra_module = THIS_MODULE,
> + .cra_list = LIST_HEAD_INIT(alg_lz4_dyn.cra_list),
> + .cra_init = lz4_init,
> + .cra_exit = lz4_exit,
> + .cra_u = { .compress = {
> + .coa_compress = lz4_compress_crypto_dynamic,
> + .coa_decompress = lz4_decompress_crypto_dynamic } }
> +};

[..]

> diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> index 4ed0a78..5bc5aab 100644
> --- a/drivers/block/zram/zcomp.c
> +++ b/drivers/block/zram/zcomp.c
> @@ -17,11 +17,15 @@
> #include <linux/crypto.h>
>
> #include "zcomp.h"
> +#define KB (1 << 10)
>
> static const char * const backends[] = {
> "lzo",
> #if IS_ENABLED(CONFIG_CRYPTO_LZ4)
> "lz4",
> +#if (PAGE_SIZE < (32 * KB))
> + "lz4_dyn",
> +#endif

This is not the list of supported algorithms. It's the list of
recommended algorithms. You can configure zram to use any of
available and known to Crypto API algorithms. Including lz4_dyn
on PAGE_SIZE > 32K systems.

-ss