Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1010724yba; Wed, 15 May 2019 14:03:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZZBId8rJqRjxVHhCHQgqsltb1xlv6O0RrsMbnm90TqkngE4KSeQ+5KHQsxJjNbJ37GpmE X-Received: by 2002:aa7:8e0d:: with SMTP id c13mr50535873pfr.193.1557954217028; Wed, 15 May 2019 14:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557954217; cv=none; d=google.com; s=arc-20160816; b=bwsPtcEsYFtaZLByTh/ukfFBPa33GZJNO+tqPO39BdYXJhrB55ZcN4/gY5DLYJ4NQW bhZT4DSwFRLYlKR2uyOyrDoxQD5Hz6qkvLuz1FPBjAHn0G+1CIvB0Yq5Lvl127DpT7og ykoQqhMMjlnJpJuRywy10Chn4SH0U9W6Tx4VyJL3gDblA9jQlSZPDFIwAjUwSCzHPP8i mLL0dOA5Dg9gR1Y254o8mSZzSQbA0CvkoYwYm25jQoceFlF1MwAdfXTDdYWqbWKAk2nE 0Rj6Nn/hM0uemoHF8Ez0L8l7AGR/7Pd/SnXI+K10bQ+nqgR2VSo84Nitai8wLTEnRJMS /GNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=DcxUgo7mG/77q9GUDpYI0PFKtC9xt5nrqqNq2fqMZLo=; b=Q+kWOsm6jB9yPcdiH+g0ombHfgq/SYAbV2NqspURHS1qZaYnOQsPW1ksPnOg2911Bu n5QPdPwsFWuSs4HqJdGXYK7odKKuyNvRcyKE3I+00qEuRTYYbyaKm7fQWOS2FmcsNpLx 0E+QCGrcF/ykC4vZWU/V6N7vS1Jni6OmzdVaa61OKIpibm0LLFnjQ1urYeWgQJUAW4Fv tK4u/lSo1MU8seo//OtvFu9sVVswhOZBk9tKVoe9KJHC0tTqHyssPa2HmAvC2joc80Hv vByasYg2a1oHaqEL7j/MVNgq83YWymLe2yYRH2qVLcXDVtGXX8x0OkO2TMMKBaWSjXOP 3kSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si2698419pgw.70.2019.05.15.14.03.22; Wed, 15 May 2019 14:03:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727885AbfEOVCP (ORCPT + 99 others); Wed, 15 May 2019 17:02:15 -0400 Received: from lilium.sigma-star.at ([109.75.188.150]:56102 "EHLO lilium.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbfEOVCP (ORCPT ); Wed, 15 May 2019 17:02:15 -0400 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 48EB71801442B; Wed, 15 May 2019 23:02:11 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Michele Dionisio , Sebastian Andrzej Siewior , Richard Weinberger Subject: [PATCH] ubifs: Add support for zstd compression. Date: Wed, 15 May 2019 23:02:02 +0200 Message-Id: <20190515210202.21169-1-richard@nod.at> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michele Dionisio zstd shows a good compression rate and is faster than lzo, also on slow ARM cores. Cc: Sebastian Andrzej Siewior Signed-off-by: Michele Dionisio [rw: rewrote commit message] Signed-off-by: Richard Weinberger --- 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