From: Emil Lenngren <emil.lenngren@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>,
linux-mtd@lists.infradead.org,
LKML <linux-kernel@vger.kernel.org>,
Michele Dionisio <michele.dionisio@gmail.com>
Subject: Re: [PATCH] ubifs: Add support for zstd compression.
Date: Fri, 7 Jun 2019 17:34:16 +0200 [thread overview]
Message-ID: <CAO1O6sdU=kAYS2sTKwiagxrbg+fMer9nvbwA9C4LoFMgH7e1dQ@mail.gmail.com> (raw)
In-Reply-To: <20190515210202.21169-1-richard@nod.at>
Hello,
Den ons 15 maj 2019 kl 23:03 skrev Richard Weinberger <richard@nod.at>:
>
> From: Michele Dionisio <michele.dionisio@gmail.com>
>
> zstd shows a good compression rate and is faster than lzo,
> also on slow ARM cores.
>
> Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
> Signed-off-by: Michele Dionisio <michele.dionisio@gmail.com>
> [rw: rewrote commit message]
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> fs/ubifs/Kconfig | 10 ++++++++++
> fs/ubifs/compress.c | 27 ++++++++++++++++++++++++++-
> fs/ubifs/super.c | 2 ++
> fs/ubifs/ubifs-media.h | 2 ++
> 4 files changed, 40 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> index 9da2f135121b..8d84d2ed096d 100644
> --- a/fs/ubifs/Kconfig
> +++ b/fs/ubifs/Kconfig
> @@ -5,8 +5,10 @@ config UBIFS_FS
> select CRYPTO if UBIFS_FS_ADVANCED_COMPR
> select CRYPTO if UBIFS_FS_LZO
> select CRYPTO if UBIFS_FS_ZLIB
> + select CRYPTO if UBIFS_FS_ZSTD
> select CRYPTO_LZO if UBIFS_FS_LZO
> select CRYPTO_DEFLATE if UBIFS_FS_ZLIB
> + select CRYPTO_ZSTD if UBIFS_FS_ZSTD
> select CRYPTO_HASH_INFO
> select UBIFS_FS_XATTR if FS_ENCRYPTION
> depends on MTD_UBI
> @@ -37,6 +39,14 @@ config UBIFS_FS_ZLIB
> help
> Zlib compresses better than LZO but it is slower. Say 'Y' if unsure.
>
> +config UBIFS_FS_ZSTD
> + bool "ZSTD compression support" if UBIFS_FS_ADVANCED_COMPR
> + depends on UBIFS_FS
> + default y
> + help
> + ZSTD compresses is a big win in speed over Zlib and
> + in compression ratio over LZO. Say 'Y' if unsure.
> +
> config UBIFS_ATIME_SUPPORT
> bool "Access time support"
> default n
> diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c
> index 565cb56d7225..89183aeeeb7a 100644
> --- a/fs/ubifs/compress.c
> +++ b/fs/ubifs/compress.c
> @@ -71,6 +71,24 @@ 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",
> +};
> +#else
> +static struct ubifs_compressor zstd_compr = {
> + .compr_type = UBIFS_COMPR_ZSTD,
> + .name = "zstd",
> +};
> +#endif
> +
> /* All UBIFS compressors */
> struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
>
> @@ -228,13 +246,19 @@ int __init ubifs_compressors_init(void)
> if (err)
> return err;
>
> - err = compr_init(&zlib_compr);
> + err = compr_init(&zstd_compr);
> if (err)
> goto out_lzo;
>
> + err = compr_init(&zlib_compr);
> + if (err)
> + goto out_zstd;
> +
> ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr;
> return 0;
>
> +out_zstd:
> + compr_exit(&zstd_compr);
> out_lzo:
> compr_exit(&lzo_compr);
> return err;
> @@ -247,4 +271,5 @@ void ubifs_compressors_exit(void)
> {
> compr_exit(&lzo_compr);
> compr_exit(&zlib_compr);
> + compr_exit(&zstd_compr);
> }
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 04b8ecfd3470..ea8615261936 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -1055,6 +1055,8 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
> c->mount_opts.compr_type = UBIFS_COMPR_LZO;
> else if (!strcmp(name, "zlib"))
> c->mount_opts.compr_type = UBIFS_COMPR_ZLIB;
> + else if (!strcmp(name, "zstd"))
> + c->mount_opts.compr_type = UBIFS_COMPR_ZSTD;
> else {
> ubifs_err(c, "unknown compressor \"%s\"", name); //FIXME: is c ready?
> kfree(name);
> diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h
> index 8b7c1844014f..697b1b89066a 100644
> --- a/fs/ubifs/ubifs-media.h
> +++ b/fs/ubifs/ubifs-media.h
> @@ -348,12 +348,14 @@ enum {
> * UBIFS_COMPR_NONE: no compression
> * UBIFS_COMPR_LZO: LZO compression
> * UBIFS_COMPR_ZLIB: ZLIB compression
> + * UBIFS_COMPR_ZSTD: ZSTD compression
> * UBIFS_COMPR_TYPES_CNT: count of supported compression types
> */
> enum {
> UBIFS_COMPR_NONE,
> UBIFS_COMPR_LZO,
> UBIFS_COMPR_ZLIB,
> + UBIFS_COMPR_ZSTD,
> UBIFS_COMPR_TYPES_CNT,
> };
>
> --
> 2.16.4
In fs/ubifs/sb.c we have
static int get_default_compressor(struct ubifs_info *c)
{
if (ubifs_compr_present(c, UBIFS_COMPR_LZO))
return UBIFS_COMPR_LZO;
if (ubifs_compr_present(c, UBIFS_COMPR_ZLIB))
return UBIFS_COMPR_ZLIB;
return UBIFS_COMPR_NONE;
}
Maybe add an entry for zstd here as well?
/Emil
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2019-06-07 15:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-15 21:02 [PATCH] ubifs: Add support for zstd compression Richard Weinberger
2019-05-16 18:23 ` Sebastian Andrzej Siewior
2019-06-07 15:34 ` Emil Lenngren [this message]
2019-06-07 20:09 ` Richard Weinberger
2019-06-07 20:27 ` Emil Lenngren
2019-06-07 20:49 ` Richard Weinberger
2019-06-07 23:40 ` Emil Lenngren
2019-06-08 8:46 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAO1O6sdU=kAYS2sTKwiagxrbg+fMer9nvbwA9C4LoFMgH7e1dQ@mail.gmail.com' \
--to=emil.lenngren@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=michele.dionisio@gmail.com \
--cc=richard@nod.at \
--cc=sebastian@breakpoint.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).