Received: by 10.213.65.68 with SMTP id h4csp1209691imn; Wed, 21 Mar 2018 05:31:31 -0700 (PDT) X-Google-Smtp-Source: AG47ELuqqGte32e6JcfiMVNNfJsHGGSZglJZCkGwQi2Z4XSvujs3rTv0j533cIKGRqwEHCxSicot X-Received: by 2002:a17:902:5a4e:: with SMTP id f14-v6mr20257200plm.116.1521635491708; Wed, 21 Mar 2018 05:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521635491; cv=none; d=google.com; s=arc-20160816; b=Ek5QNAte3wXuP/MZPpuGBFbRadzky04k5gQPzWAmjg30T8lgCe8ZtfqhDBj+eQOwSm z64E27MIZ2kdpgFubDs5MV3j6NbM1A73xpyGRkwtjnccKidlkerUdrwA0n4ybra6Qo7N KHUmkKgbbAD86z0x2JP7YIwww453GcZ/7iVDvu6qWj+0AjxFRQiqtH9JK/qt6DvxO9No LnNFrVO7PyBAAICUZ4SMWPcCM+r8pS3n2R2/6V/KQMRpALdsTEoS08NUqkrmtoS81dra Uu71wWmw8fJZMOac+ku3k1q9WI+FwEFe5uZfAWRMkXBky7gT6ruMVyO8DqPSwNTTieaM dRaQ== 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 :dkim-signature:arc-authentication-results; bh=tmp4IdL7So/AUak1ToWToTYUXyGWGFBVTBU8MAntrew=; b=w19Vu/Dn6jDNTf2DyyEkJhntdoVIIp4q4GiWyVXnhicKXX2wZiWB/+T+8jXKru/B22 Ap7nrsoeiZ/2N1I3jbQXGAf/M101b+CemFLkMNHpAuDS7j5JCAETo0+S6imDYHwu88JP 7uTLYDVRmcwC5El/k+Adlg+cxvgd3faO2nw13cz9LA0j6PhPAJVX8Lr5hycVVBT/6gym aQRmTcxcDkfKDoCQHYoxLdyJ1V21o3K39+Iinxw2gbm74hfjMmEHUh5XXPjUj69naCR/ yH7WbxaD/oaGMV9wmSjX3pTcgbGEdw6FcjsdUsgWlPWUuhDqeEaNpq2PE3JvVPahhDSg NmCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SNEqoaQk; 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 v20-v6si3555710plo.199.2018.03.21.05.31.17; Wed, 21 Mar 2018 05:31:31 -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=SNEqoaQk; 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 S1752057AbeCUM3i (ORCPT + 99 others); Wed, 21 Mar 2018 08:29:38 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:46923 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751778AbeCUM3h (ORCPT ); Wed, 21 Mar 2018 08:29:37 -0400 Received: by mail-pl0-f67.google.com with SMTP id f5-v6so2990779plj.13 for ; Wed, 21 Mar 2018 05:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=tmp4IdL7So/AUak1ToWToTYUXyGWGFBVTBU8MAntrew=; b=SNEqoaQk8b5wGxQrD4Ds4lgjZjHfLD49L6oyBY67qB+xhmBIQkrM2aqYxb0xEXH2wE OWuVDvBKLEn5mQlMlWVsKegD03SJrT4eVc+qZaBLUXFDxhL03MtDfQMeXCCCkeQpLtcu 48VArhI0e0MyQe05Z0FoCl3aEFVMlONxatvZWGxzZFSm6uUKYu2RmTME+iXcscP9NEMv +8bEuagGrZE/zejELW7hk6B27rbOBYZRHoRfHhDxC/NsZs+FUuVKrQScgo+gtacJKR1m y+KdjXFYAVtg/1QexCMIo4lP4PyRnacx8+lPIRGIr4vhqNCw1fvLYWZ+P+HR3Kh1MwI5 2atg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tmp4IdL7So/AUak1ToWToTYUXyGWGFBVTBU8MAntrew=; b=eueevaG0dKDlTAplz3t3ISN0ELrVw5w/cLK1vPXOY+wraArmu3r9CdKjJ2yd1UbKDT wEVJ0m7j8IYC/2wh0J653Vmvye8ZT+5+VLtlzJfVndyhee8fF0yzn5/wyuEDMZ1hSpey gtY94BsOaV8G2hqiDNPIHoR+0xLykZM8Z9b1nGT+PezgS9AfHs3O+EmavVOhGmRo3X6t u8WnmoljUnKJ/IHWP4vwIxPGsqnmtwNFtm/SSLZQVMgKAQ7xRILQtR7nDv65Nw4yZuaK fWJDUttpBC5l0xYbGmPlGguqtW0s+ZXUnGSZBpULwtQArjf2D5npYcIGwMK3nHaXjWo1 0rCA== X-Gm-Message-State: AElRT7F4UrYzR2DP7jb4zU5BGcuypd8J3MzxD00GRg2d1iFeZOTeohgw TiBtbS1ptlirQzqyNZzoO20= X-Received: by 2002:a17:902:a9c7:: with SMTP id b7-v6mr20152772plr.190.1521635376766; Wed, 21 Mar 2018 05:29:36 -0700 (PDT) Received: from localhost ([114.255.3.133]) by smtp.gmail.com with ESMTPSA id v18sm7655825pgb.23.2018.03.21.05.29.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 05:29:36 -0700 (PDT) From: Geliang Tang To: Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck Cc: Geliang Tang , linux-kernel@vger.kernel.org Subject: [PATCH] pstore: add zstd compression support Date: Wed, 21 Mar 2018 20:29:31 +0800 Message-Id: <9c9416b2dff19f05fb4c35879aaa83d11ff72c92.1521626182.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch added the 6th compression algorithm support for pstore: zstd. Signed-off-by: Geliang Tang --- Depend on 'crypto: Add zstd support' by Nick Terrell --- fs/pstore/Kconfig | 17 ++++++++++++++--- fs/pstore/platform.c | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 09c19ef91526..63cf4813559a 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -50,12 +50,19 @@ config PSTORE_842_COMPRESS help This option enables 842 compression algorithm support. +config PSTORE_ZSTD_COMPRESS + tristate "zstd compression" + depends on PSTORE + select CRYPTO_ZSTD + help + This option enables zstd compression algorithm support. + config PSTORE_COMPRESS def_bool y depends on PSTORE depends on PSTORE_DEFLATE_COMPRESS || PSTORE_LZO_COMPRESS || \ PSTORE_LZ4_COMPRESS || PSTORE_LZ4HC_COMPRESS || \ - PSTORE_842_COMPRESS + PSTORE_842_COMPRESS || PSTORE_ZSTD_COMPRESS choice prompt "Default pstore compression algorithm" @@ -65,8 +72,8 @@ choice This change be changed at boot with "pstore.compress=..." on the kernel command line. - Currently, pstore has support for 5 compression algorithms: - deflate, lzo, lz4, lz4hc and 842. + Currently, pstore has support for 6 compression algorithms: + deflate, lzo, lz4, lz4hc, 842 and zstd. The default compression algorithm is deflate. @@ -85,6 +92,9 @@ choice config PSTORE_842_COMPRESS_DEFAULT bool "842" if PSTORE_842_COMPRESS + config PSTORE_ZSTD_COMPRESS_DEFAULT + bool "zstd" if PSTORE_ZSTD_COMPRESS + endchoice config PSTORE_COMPRESS_DEFAULT @@ -95,6 +105,7 @@ config PSTORE_COMPRESS_DEFAULT default "lz4" if PSTORE_LZ4_COMPRESS_DEFAULT default "lz4hc" if PSTORE_LZ4HC_COMPRESS_DEFAULT default "842" if PSTORE_842_COMPRESS_DEFAULT + default "zstd" if PSTORE_ZSTD_COMPRESS_DEFAULT config PSTORE_CONSOLE bool "Log kernel console messages" diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 1143ef351c58..9df8cdc378f5 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -34,6 +34,9 @@ #if IS_ENABLED(CONFIG_PSTORE_LZ4_COMPRESS) || IS_ENABLED(CONFIG_PSTORE_LZ4HC_COMPRESS) #include #endif +#if IS_ENABLED(CONFIG_PSTORE_ZSTD_COMPRESS) +#include +#endif #include #include #include @@ -192,6 +195,13 @@ static int zbufsize_842(size_t size) } #endif +#if IS_ENABLED(CONFIG_PSTORE_ZSTD_COMPRESS) +static int zbufsize_zstd(size_t size) +{ + return ZSTD_compressBound(size); +} +#endif + static const struct pstore_zbackend *zbackend __ro_after_init; static const struct pstore_zbackend zbackends[] = { @@ -224,6 +234,12 @@ static const struct pstore_zbackend zbackends[] = { .zbufsize = zbufsize_842, .name = "842", }, +#endif +#if IS_ENABLED(CONFIG_PSTORE_ZSTD_COMPRESS) + { + .zbufsize = zbufsize_zstd, + .name = "zstd", + }, #endif { } }; -- 2.14.1