Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp329362ybi; Fri, 7 Jun 2019 08:43:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCmbOi2ZlsNiCJ4HlVXiGIReHcaqjtEuT76hXKNF/N+HB/onD9fMD7bQZPHoSGCVwY/RdW X-Received: by 2002:a17:902:6b03:: with SMTP id o3mr56201701plk.85.1559922216660; Fri, 07 Jun 2019 08:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559922216; cv=none; d=google.com; s=arc-20160816; b=zwcOnAghe4t6uMGnGG0iF+C4Ftbac4qMKyUc0R3QKTt6Euw2/iUbSGFxHfIxywXquC Sw96sbIXMtK7BCo54A2qozmHJHIqwTFrVvSOtstLGlySb0dvnxjWP9DtZw0VcgYHLii/ hhxqSj/hlq6/67AqqAJcyv1LKTsSMRKQlCzzUaDCvx+NguMJY2vxomQXDeKJ01nElX5W Jbi1WpE5ucyamqh/i1ZwAImVuhicAq7ii5lUlSJvtck7WWCRq6znrK/KHMx2QRE3av3t N6h9iQtmATSd9gtFOsAWEjev2sD9LhvmVnUrJVp6gWqYq5FTSiQpV1TyMy+YhUw147NC o+QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=h1nKFwhuq2ZEy0/ENH2G+07fPOyOK64gti3KBgl78Rg=; b=szPyXqN9zpLMhu4NIEBH3YZZEpGEfiIrnkRfp1z+GMYZosT9/wdR5SgeuGios+bjZO LfewkxQsRq8dmnkYvk+mpUUBF0kCiltGlXjK1oXKPfd8EEl4rsqU9nDG9mBnQzdUc869 908jp7X7RqbRBpz188nmzxR1qewszUogiIFl5xDqDS5Det4YA/oniK3K40mSC5oFbM1E b2RVIkkDGvGuUqDzAkCWl8z5al1enbTPjRu1xuNRdoW+QEZaqWTs8HEMGjf2UvYpMNb6 UTDq0KF60YyLzrJcRXI3MrOnTzOESkjz9ZB2iX8cIYGwXOQTgplWbvhFZv7/MhQp+bqE 4nwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qyOSfdjE; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7si2049890pgq.453.2019.06.07.08.43.19; Fri, 07 Jun 2019 08:43:36 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qyOSfdjE; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729827AbfFGPe3 (ORCPT + 99 others); Fri, 7 Jun 2019 11:34:29 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38364 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729047AbfFGPe3 (ORCPT ); Fri, 7 Jun 2019 11:34:29 -0400 Received: by mail-pl1-f193.google.com with SMTP id f97so974763plb.5 for ; Fri, 07 Jun 2019 08:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h1nKFwhuq2ZEy0/ENH2G+07fPOyOK64gti3KBgl78Rg=; b=qyOSfdjE5eweGadE+c1zpwMdiopx6p5B6y5hDjgg7mxbdYLW+L8J24CH5j4tGB24zV frtVpsgEqgv6t0pEMPRIxFRqVIX0XgCddlV3xDyn1kxpBLE035ZJQOz6kto8nCXg+UZf 3l7L9b+cHyqGyCAwfT9+M4kKBg68+6SbY8qKCBLm2/GJrIinPcHKCZSBbzw38kfTeMMU EMojC7jY+x/kucJIy1Ah1RqjKjPV4mWyT+oJ0ADB487CKYFz6hkJsgu7L1BlqgPV+3Uf F6o4XVJKM5m2ohulV2gmIEOi8xdfpLXSLNqRCIqfa2kMPX3Ry3A3L97uY65WipPofcEt 6mgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h1nKFwhuq2ZEy0/ENH2G+07fPOyOK64gti3KBgl78Rg=; b=fiuqs38Q6J2Vaov+dK1mhfZ3UU0DJ+SsDYyJbfvy7AySbMjNUWqiKJtmMr8OEUn2Fm /lMUW27opCrN4XbGH33MXnmMFjFGPwIB3ZRWIxGL9Uy8rl/RvBl9M+f2+4l8SI9vjQ9T hTDzAJNDESTzcTlMyXo48tvOObFm2hQ9yktgujeOZKVe03tl8HyZO7ESEV423QDIY7rI Ug5aWhTlQp9qoQctoig3OwFWS1dam82l4RJ6B2oj516X75A03OQIrVI6LDC1rEKTjNVv vzvgl24BPutt/ic/TFcJLDLSeyNrOpZbMitr370BFv/9z5y6TrcI/TziQRq8WMwejMaf 14DQ== X-Gm-Message-State: APjAAAW/4PNlkoXbkMFbJeknBi081xQ8PvC1nmXcpXEmJCAnq8gbjBWs 3d8Bs2aWNyBrrzfzpLGVV9QX+dPtGYo73wnzyrE= X-Received: by 2002:a17:902:112c:: with SMTP id d41mr55075010pla.33.1559921668118; Fri, 07 Jun 2019 08:34:28 -0700 (PDT) MIME-Version: 1.0 References: <20190515210202.21169-1-richard@nod.at> In-Reply-To: <20190515210202.21169-1-richard@nod.at> From: Emil Lenngren Date: Fri, 7 Jun 2019 17:34:16 +0200 Message-ID: Subject: Re: [PATCH] ubifs: Add support for zstd compression. To: Richard Weinberger Cc: linux-mtd@lists.infradead.org, Sebastian Andrzej Siewior , LKML , Michele Dionisio Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Den ons 15 maj 2019 kl 23:03 skrev Richard Weinberger : > > 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 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