Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp726850imm; Wed, 1 Aug 2018 04:25:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpflpx3cU5HuH5q08ogP62xFSzgGVxXA0XDPeRDzPWP0ZI7bSfqjMV558nW15mRYPflYvKFk X-Received: by 2002:a65:64c8:: with SMTP id t8-v6mr23999942pgv.110.1533122733783; Wed, 01 Aug 2018 04:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533122733; cv=none; d=google.com; s=arc-20160816; b=Pa3lMYk0T9ZClv1cMxGT6lKRZOaGnJOsGuyOoYhK7glqTrXkbqGpHb+X6GSXHV40IE YBhlDPZ8xf3J1k3fZfhY7DoBucxPoyEINIrgNkH9pziyjwP1d/QTPNHlFu/ueywAPOnQ KoClQOC2l3ELtGAhjOwr0x6LBjCsBJw7GUk/I8oJt9cuyYHE40FHMxhlrm7s0WDbQChG e/HuwfQNeala1Po82U1jgRnup8yikuJwzZ4XQOqLpe/EiZotmT9xw0KWC5NHcgpbZpzF orCJtZwCAVcYH0mRclEW+60DbQHKOzbhX5z7EsYXJgFhE7lEotNXZq2PHWzj8IKZk/fu N+ZQ== 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=hrGARehJF+jE98FBlH8fXHCKOio57TlVwx/8oU41KwI=; b=Hggsxl7tWy40dP4SF4b2q9H557p3rpNVl1T9hoabPS6cd/azajCFjvHSWQVHbafN2W seBjjX6EABucV3ZWiTiMzuPDiUinRF//vaFN2lr1WpIC3DC+S0SF9n1CE78g7uPud/Kh lpsJ43zrBaUgdZoYEXy+Gs36WbHv4pIILZvx35hVDIBdWXWQQkGKQHWIwlR5TZtnxSIv jqT1jTaY+1zbp12oGUWUzStHwomQM8CX7sLYm/plf0iwLJ3UbbpRnkMG/wiUcRuCzIS2 9fKMm3JFxb9nctjUShvxarTBwTIUOhDb7qI4vL4CoonsClUD3Jof1xs+A4AdGR829y1f 0lcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CNzo6+1Z; 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 m4-v6si14955679pll.461.2018.08.01.04.25.19; Wed, 01 Aug 2018 04:25:33 -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=CNzo6+1Z; 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 S2388830AbeHANJG (ORCPT + 99 others); Wed, 1 Aug 2018 09:09:06 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:34153 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388565AbeHANJG (ORCPT ); Wed, 1 Aug 2018 09:09:06 -0400 Received: by mail-pl0-f68.google.com with SMTP id f6-v6so8669640plo.1 for ; Wed, 01 Aug 2018 04:23:47 -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=hrGARehJF+jE98FBlH8fXHCKOio57TlVwx/8oU41KwI=; b=CNzo6+1Z8S8n7ltoStYYeoAjxnrfEsck7qyQ0G8yun9LqLEk6CZA99J4dtWvpocnS7 gpkTzm9hgcwOr+xFbLG3o2UGN6Q7eH61cK+r0ag6bAOoGp85DA2aW1F9utal5qGdYmoR hUFac6AM6MBcFQh23ep43z88P8HZ0sUDN6NoO5DJA0YyagMcW1wXZPkz9EpaYU/m8aN8 DGR003Quk8s7C6sjKKNui27iXd7lWYl3npug2S9Ejq96fV7xoWrGxY1yvNved7KeVQNM NubkuHGTBQvswNswE19tj86pLfAGibRyjPrVL2qNGuyHIvNxIWfvHejvkhfnGcDm2MuD 3kJw== 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=hrGARehJF+jE98FBlH8fXHCKOio57TlVwx/8oU41KwI=; b=bcTIjJv5oPBr/7V9J3qFw4435oNcAeCyd2zb1bNmIQrNLoNUVva8B5J32IiS/icRP1 S6RbH18KlZn1dK7Z/OZKoqiZCPNrz/635AArz6Md0EsDwK1zCM+ZDxXirW55Ip6SisFs /sncj5PwX4tru+eDVsLQvkUNnbnR/A76Kql4opI0Wv2q6YXwSJb9dnJJP3KH9i8XpbBF w7/sieCnlBxk8hR19o7BgOXHfTI55gJeV/qUPAA0dI9udjk9oPHQs9IaAQKPN1bBfc9/ eiwb8BNk/JdXYmKa2seVj5GRUc51/FHzIoA2zzHT6+twFs8m0wYQjbDZz721j4+/r77P kIAQ== X-Gm-Message-State: AOUpUlEokWM9/ceDGUDULaEgOrTylhj57zrt8MO1y+X846uNbVXYId6N KNhAfVtiYdWAeUuZHsWz2Ck= X-Received: by 2002:a17:902:8f8e:: with SMTP id z14-v6mr23982032plo.139.1533122626818; Wed, 01 Aug 2018 04:23:46 -0700 (PDT) Received: from localhost (outboundhk.mxmail.xiaomi.com. [207.226.244.123]) by smtp.gmail.com with ESMTPSA id n24-v6sm36131543pfi.161.2018.08.01.04.23.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 04:23:46 -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, 1 Aug 2018 19:23:37 +0800 Message-Id: <8da60549d9c649bc6f00cd82f70464b982ecb2a0.1533122560.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.17.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 --- 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 c238ab8ba31d..15e99d5a681d 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.17.1