lz4hc compression in UBIFS?
Konstantin Tokarev
annulen at yandex.ru
Fri Oct 4 01:06:02 PDT 2013
04.10.2013, 07:09, "Brent Taylor" <motobud at gmail.com>:
> Here is a patch based on linux-3.12-rc3. I haven't performed any
> performance testing UBIFS using lz4hc, but I can mount UBIFS volumes
> and haven't seen any problems yet.
Thank you!
Are you planning to implement a patch for mtd-utils (mkfs.ubifs) as well?
> The only think I know that isn't
> correct about the patch is the description for the Kconfig element for
> select lz4hc as a compression option. I only copied the description
> from the lzo description.
>
> diff -uN -uNr linux-3.12-rc3.orig/fs/ubifs/compress.c
> linux-3.12-rc3/fs/ubifs/compress.c
> --- linux-3.12-rc3.orig/fs/ubifs/compress.c 2013-09-29
> 17:02:38.000000000 -0500
> +++ linux-3.12-rc3/fs/ubifs/compress.c 2013-07-17 21:57:27.440653860 -0500
> @@ -53,6 +53,22 @@
> };
> #endif
>
> +#ifdef CONFIG_UBIFS_FS_LZ4HC
> +static DEFINE_MUTEX(lz4hc_mutex);
> +
> +static struct ubifs_compressor lz4hc_compr = {
> + .compr_type = UBIFS_COMPR_LZ4HC,
> + .comp_mutex = &lz4hc_mutex,
> + .name = "lz4hc",
> + .capi_name = "lz4hc",
> +};
> +#else
> +static struct ubifs_compressor lz4hc_compr = {
> + .compr_type = UBIFS_COMPR_LZ4HC,
> + .name = "lz4hc",
> +};
> +#endif
> +
> #ifdef CONFIG_UBIFS_FS_ZLIB
> static DEFINE_MUTEX(deflate_mutex);
> static DEFINE_MUTEX(inflate_mutex);
> @@ -224,10 +240,14 @@
> {
> int err;
>
> - err = compr_init(&lzo_compr);
> + err = compr_init(&lz4hc_compr);
> if (err)
> return err;
>
> + err = compr_init(&lzo_compr);
> + if (err)
> + goto out_lz4hc;
> +
> err = compr_init(&zlib_compr);
> if (err)
> goto out_lzo;
> @@ -237,6 +257,8 @@
>
> out_lzo:
> compr_exit(&lzo_compr);
> +out_lz4hc:
> + compr_exit(&lz4hc_compr);
> return err;
> }
>
> @@ -245,6 +267,7 @@
> */
> void ubifs_compressors_exit(void)
> {
> + compr_exit(&lz4hc_compr);
> compr_exit(&lzo_compr);
> compr_exit(&zlib_compr);
> }
> diff -uN -uNr linux-3.12-rc3.orig/fs/ubifs/Kconfig
> linux-3.12-rc3/fs/ubifs/Kconfig
> --- linux-3.12-rc3.orig/fs/ubifs/Kconfig 2013-09-29
> 17:02:38.000000000 -0500
> +++ linux-3.12-rc3/fs/ubifs/Kconfig 2013-10-03 21:40:39.098747630 -0500
> @@ -29,6 +29,14 @@
> LZO compressor is generally faster than zlib but compresses worse.
> Say 'Y' if unsure.
>
> +config UBIFS_FS_LZ4HC
> + bool "LZ4HC compression support" if UBIFS_FS_ADVANCED_COMPR
> + depends on UBIFS_FS && CRYPTO_LZ4HC
> + default y
> + help
> + LZ4HC compressor is generally faster than zlib but compresses worse.
> + Say 'Y' if unsure.
> +
> config UBIFS_FS_ZLIB
> bool "ZLIB compression support" if UBIFS_FS_ADVANCED_COMPR
> depends on UBIFS_FS
> diff -uN -uNr linux-3.12-rc3.orig/fs/ubifs/super.c
> linux-3.12-rc3/fs/ubifs/super.c
> --- linux-3.12-rc3.orig/fs/ubifs/super.c 2013-09-29
> 17:02:38.000000000 -0500
> +++ linux-3.12-rc3/fs/ubifs/super.c 2013-09-30 23:01:06.899526709 -0500
> @@ -1040,6 +1040,8 @@
> return -ENOMEM;
> if (!strcmp(name, "none"))
> c->mount_opts.compr_type = UBIFS_COMPR_NONE;
> + else if (!strcmp(name, "lz4hc"))
> + c->mount_opts.compr_type = UBIFS_COMPR_LZ4HC;
> else if (!strcmp(name, "lzo"))
> c->mount_opts.compr_type = UBIFS_COMPR_LZO;
> else if (!strcmp(name, "zlib"))
> diff -uN -uNr linux-3.12-rc3.orig/fs/ubifs/ubifs-media.h
> linux-3.12-rc3/fs/ubifs/ubifs-media.h
> --- linux-3.12-rc3.orig/fs/ubifs/ubifs-media.h 2013-09-29
> 17:02:38.000000000 -0500
> +++ linux-3.12-rc3/fs/ubifs/ubifs-media.h 2013-07-16
> 22:56:02.435523610 -0500
> @@ -332,12 +332,14 @@
> * UBIFS_COMPR_NONE: no compression
> * UBIFS_COMPR_LZO: LZO compression
> * UBIFS_COMPR_ZLIB: ZLIB compression
> + * UBIFS_COMPR_LZ4HZ: LZ4HZ compression
> * UBIFS_COMPR_TYPES_CNT: count of supported compression types
> */
> enum {
> UBIFS_COMPR_NONE,
> UBIFS_COMPR_LZO,
> UBIFS_COMPR_ZLIB,
> + UBIFS_COMPR_LZ4HC,
> UBIFS_COMPR_TYPES_CNT,
> };
>
> Enjoy,
> Brent Taylor
--
Regards,
Konstantin
More information about the linux-mtd
mailing list