From patchwork Wed Oct 14 07:38:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 7391101 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC091BEEA4 for ; Wed, 14 Oct 2015 07:40:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD3A9207A6 for ; Wed, 14 Oct 2015 07:40:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A879C20793 for ; Wed, 14 Oct 2015 07:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbbJNHjo (ORCPT ); Wed, 14 Oct 2015 03:39:44 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33279 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753039AbbJNHi4 (ORCPT ); Wed, 14 Oct 2015 03:38:56 -0400 Received: by pabrc13 with SMTP id rc13so46672055pab.0; Wed, 14 Oct 2015 00:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tekNZ6cHAj8lUVoO6c93Fd4+sew23NTIqzXKOSVDw9I=; b=tgveykQMvYFoPlfkp4ICDkjvjhErTiSkw3/tIlMLGf1R5C4E1BsuDUV+qmWQqL1fHz Unz8LWDCeLYYbn2tg32LOaWqCX9l/Y6RvGvvHxvMMWI4/BvmFT3kSvldlb1xmgFsXtBN oFYMy+pB+Adykpm6CUGLn16Qe0oQTsiOERGgLftO0qAr2A0N5JLKLcQlwZX1kd2ZCz7P 18FY9Qht+xpHqNZbBSH0GWhbLMpecyqTMvz2MQVrkNDXwOo4Rx5MVX5T0UwxiVFqPpcW iUQsG5sNPZkYrI/4oEYgGku4UNxzBuCr+/ukOr67nt9d/434Cl/9sx31nHK2VbmT6f+5 DsQA== X-Received: by 10.68.249.34 with SMTP id yr2mr2157884pbc.73.1444808336214; Wed, 14 Oct 2015 00:38:56 -0700 (PDT) Received: from localhost.localdomain ([119.69.155.252]) by smtp.gmail.com with ESMTPSA id qr8sm4147173pbb.47.2015.10.14.00.38.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Oct 2015 00:38:55 -0700 (PDT) From: Joonsoo Kim X-Google-Original-From: Joonsoo Kim To: Andrew Morton Cc: Minchan Kim , Nitin Gupta , Sergey Senozhatsky , Herbert Xu , "David S. Miller" , Stephan Mueller , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Joonsoo Kim Subject: [PATCH v4 8/8] zram: enable contextless compression alg in zram Date: Wed, 14 Oct 2015 16:38:24 +0900 Message-Id: <1444808304-29320-9-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444808304-29320-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1444808304-29320-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now, zram uses contextless compression API and there is no reason to limit compression algorithm through hard-wired string. This patch remove it so enable all contextless compression algorithm in the system. After this patch, available compression algorithm for zram can be retrieved by searching contextless compression in /proc/crypto. cat /proc/crypto | grep ccomp -B 7 name : lz4 [snip...] type : ccomp Previous interface comp_algorithm attr will remain to set new algorithm. Read from previous interface also works for compatibility but it will be wrong. Note that after this patch is applied, there is no way to know current compression algorithm so it's really bad thing. Please let me know proper solution if someone have better idea. Signed-off-by: Joonsoo Kim --- Documentation/blockdev/zram.txt | 29 +++++++++++++++++++++++------ drivers/block/zram/Kconfig | 9 --------- drivers/block/zram/zcomp.c | 17 +++++++---------- drivers/block/zram/zram_drv.c | 1 + 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt index 5bda503..7a165c2 100644 --- a/Documentation/blockdev/zram.txt +++ b/Documentation/blockdev/zram.txt @@ -81,15 +81,32 @@ dynamic max_comp_streams. Only multi stream backend supports dynamic max_comp_streams adjustment. 3) Select compression algorithm - Using comp_algorithm device attribute one can see available and - currently selected (shown in square brackets) compression algorithms, - change selected compression algorithm (once the device is initialised - there is no way to change compression algorithm). + You can find available compression algorithms by searching contextless + compression algorithm (type: ccomp) in /proc/crypto. + Using comp_algorithm device attribute one can change selected + compression algorithm (once the device is initialised there is no way + to change compression algorithm). Examples: #show supported compression algorithms - cat /sys/block/zram0/comp_algorithm - lzo [lz4] + cat /proc/crypto | grep ccomp -B 7 + name : lz4 + driver : lz4-generic + module : kernel + priority : 0 + refcnt : 1 + selftest : passed + internal : no + type : ccomp + -- + name : lzo + driver : lzo-generic + module : kernel + priority : 0 + refcnt : 1 + selftest : passed + internal : no + type : ccomp #select lzo compression algorithm echo lzo > /sys/block/zram0/comp_algorithm diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 7619bed..36ec96f 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -13,12 +13,3 @@ config ZRAM disks and maybe many more. See zram.txt for more information. - -config ZRAM_LZ4_COMPRESS - bool "Enable LZ4 algorithm support" - depends on ZRAM - select CRYPTO_LZ4 - default n - help - This option enables LZ4 compression algorithm support. Compression - algorithm can be changed using `comp_algorithm' device attribute. diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index 9be83db..f91c0659 100644 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c @@ -41,22 +41,16 @@ struct zcomp_strm_multi { static const char * const backends[] = { "lzo", -#ifdef CONFIG_ZRAM_LZ4_COMPRESS "lz4", -#endif NULL }; static const char *find_backend(const char *compress) { - int i = 0; - while (backends[i]) { - if (sysfs_streq(compress, backends[i]) && - crypto_has_comp(backends[i], 0, 0)) - break; - i++; - } - return backends[i]; + if (crypto_has_comp(compress, 0, 0)) + return compress; + + return NULL; } static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm) @@ -277,6 +271,9 @@ ssize_t zcomp_available_show(const char *comp, char *buf) int i = 0; while (backends[i]) { + if (!crypto_has_comp(backends[i], 0, 0)) + continue; + if (!strcmp(comp, backends[i])) sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2, "[%s] ", backends[i]); diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 6f04fb2..6b4cf85 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -352,6 +352,7 @@ static ssize_t comp_algorithm_show(struct device *dev, size_t sz; struct zram *zram = dev_to_zram(dev); + deprecated_attr_warn("comp_algorithm"); down_read(&zram->init_lock); sz = zcomp_available_show(zram->compressor, buf); up_read(&zram->init_lock);