All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] ubifs: Add zstd support
@ 2018-01-12  9:24 Yufen Yu
  2018-01-12 10:45 ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Yufen Yu @ 2018-01-12  9:24 UTC (permalink / raw)
  To: richard, dedekind1, adrian.hunter; +Cc: linux-kernel, linux-mtd, Yufen Yu

Add zstd compression and decompression support to ubifs. zstd at its
fastest level compresses almost as well as zlib, while offering much
faster compression and decompression, approaching lzo speeds.

This patch is based on the patch:
	https://patchwork.kernel.org/patch/9892631/

zstd source repository: https://github.com/facebook/zstd

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 fs/ubifs/Kconfig       | 10 ++++++++++
 fs/ubifs/compress.c    | 25 +++++++++++++++++++++++++
 fs/ubifs/ubifs-media.h |  2 ++
 3 files changed, 37 insertions(+)

diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
index 83a961b..056a81b 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_XZ
 	depends on MTD_UBI
 	help
 	  UBIFS is a file system for flash devices which works on top of UBI.
@@ -36,6 +38,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" if UBIFS_FS
 	depends on UBIFS_FS
diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c
index 565cb56..b310d6f 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,6 +246,10 @@ int __init ubifs_compressors_init(void)
 	if (err)
 		return err;
 
+	err = compr_init(&zstd_compr);
+	if (err)
+		goto out_zstd;
+
 	err = compr_init(&zlib_compr);
 	if (err)
 		goto out_lzo;
@@ -235,6 +257,8 @@ int __init ubifs_compressors_init(void)
 	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/ubifs-media.h b/fs/ubifs/ubifs-media.h
index e8c23c9..9f869c7 100644
--- a/fs/ubifs/ubifs-media.h
+++ b/fs/ubifs/ubifs-media.h
@@ -341,12 +341,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.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] ubifs: Add zstd support
  2018-01-12  9:24 [RFC PATCH] ubifs: Add zstd support Yufen Yu
@ 2018-01-12 10:45 ` Richard Weinberger
  2018-01-16  6:16   ` yuyufen
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2018-01-12 10:45 UTC (permalink / raw)
  To: Yufen Yu; +Cc: dedekind1, adrian.hunter, linux-kernel, linux-mtd

Yufen Yu,

Am Freitag, 12. Januar 2018, 10:24:21 CET schrieb Yufen Yu:
> Add zstd compression and decompression support to ubifs. zstd at its
> fastest level compresses almost as well as zlib, while offering much
> faster compression and decompression, approaching lzo speeds.
> 
> This patch is based on the patch:
> 	https://patchwork.kernel.org/patch/9892631/
> 
> zstd source repository: https://github.com/facebook/zstd

Do you have numbers on how much we gain for UBIFS on a typical embedded 
device?

Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] ubifs: Add zstd support
  2018-01-12 10:45 ` Richard Weinberger
@ 2018-01-16  6:16   ` yuyufen
  2018-01-16 10:55     ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: yuyufen @ 2018-01-16  6:16 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: dedekind1, adrian.hunter, linux-kernel, linux-mtd

On 2018/1/12 18:45, Richard Weinberger wrote:
> Yufen Yu,
>
> Am Freitag, 12. Januar 2018, 10:24:21 CET schrieb Yufen Yu:
>> Add zstd compression and decompression support to ubifs. zstd at its
>> fastest level compresses almost as well as zlib, while offering much
>> faster compression and decompression, approaching lzo speeds.
>>
>> This patch is based on the patch:
>> 	https://patchwork.kernel.org/patch/9892631/
>>
>> zstd source repository: https://github.com/facebook/zstd
> Do you have numbers on how much we gain for UBIFS on a typical embedded
> device?
>
> Thanks,
> //richard
>
> .
>

This is a RFC patch. I will post the test results after the full 
function completing.

Thanks a lot.

Yufen Yu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] ubifs: Add zstd support
  2018-01-16  6:16   ` yuyufen
@ 2018-01-16 10:55     ` Richard Weinberger
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2018-01-16 10:55 UTC (permalink / raw)
  To: yuyufen; +Cc: dedekind1, adrian.hunter, linux-kernel, linux-mtd

Am Dienstag, 16. Januar 2018, 07:16:44 CET schrieb yuyufen:
> On 2018/1/12 18:45, Richard Weinberger wrote:
> > Yufen Yu,
> > 
> > Am Freitag, 12. Januar 2018, 10:24:21 CET schrieb Yufen Yu:
> >> Add zstd compression and decompression support to ubifs. zstd at its
> >> fastest level compresses almost as well as zlib, while offering much
> >> faster compression and decompression, approaching lzo speeds.
> >> 
> >> This patch is based on the patch:
> >> 	https://patchwork.kernel.org/patch/9892631/
> >> 
> >> zstd source repository: https://github.com/facebook/zstd
> > 
> > Do you have numbers on how much we gain for UBIFS on a typical embedded
> > device?
> > 
> > Thanks,
> > //richard
> > 
> > .
> 
> This is a RFC patch. I will post the test results after the full
> function completing.

Well, I have nothing against adding zstd support to UBIFS, if you can show 
that it is useful and can explain why we should use zstd and not another 
modern compressor.

Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-16 10:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-12  9:24 [RFC PATCH] ubifs: Add zstd support Yufen Yu
2018-01-12 10:45 ` Richard Weinberger
2018-01-16  6:16   ` yuyufen
2018-01-16 10:55     ` Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.