mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joonsoo Kim <js1304@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Stephan Mueller <smueller@chronox.de>,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: [PATCH v4 8/8] zram: enable contextless compression alg in zram
Date: Wed, 14 Oct 2015 16:38:24 +0900	[thread overview]
Message-ID: <1444808304-29320-9-git-send-email-iamjoonsoo.kim@lge.com> (raw)
In-Reply-To: <1444808304-29320-1-git-send-email-iamjoonsoo.kim@lge.com>

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 <iamjoonsoo.kim@lge.com>
---
 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);
-- 
1.9.1


  parent reply	other threads:[~2015-10-14  7:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14  7:38 [PATCH v4 0/8] zram: introduce contextless compression API and use it on zram Joonsoo Kim
2015-10-14  7:38 ` [PATCH v4 1/8] crypto/compress: introduce contextless compression and remove unused pcomp Joonsoo Kim
2015-10-14  7:38 ` [PATCH v4 2/8] crypto/lzo: support contextless compression API Joonsoo Kim
2015-10-14  7:38 ` [PATCH v4 3/8] crypto/lz4: support contextless compressiona API Joonsoo Kim
2015-10-14  8:38   ` kbuild test robot
2015-10-14  7:38 ` [PATCH v4 4/8] crypto/deflate: support contextless compression API Joonsoo Kim
2015-10-14  8:33   ` kbuild test robot
2015-10-14 10:08   ` kbuild test robot
2015-10-14 10:26   ` kbuild test robot
2015-10-14  7:38 ` [PATCH v4 5/8] zram: make stream find and release functions static Joonsoo Kim
2015-10-14  7:38 ` [PATCH v4 6/8] zram: pass zstrm down to decompression path Joonsoo Kim
2015-10-14  7:38 ` [PATCH v4 7/8] zram: use crypto contextless compression API to (de)compress Joonsoo Kim
2015-10-15  0:38   ` Sergey Senozhatsky
2015-10-15  1:07     ` Joonsoo Kim
2015-10-15  1:53       ` Sergey Senozhatsky
2015-10-14  7:38 ` Joonsoo Kim [this message]
2015-10-15  0:29   ` [PATCH v4 8/8] zram: enable contextless compression alg in zram Sergey Senozhatsky
2015-10-15  0:45     ` Joonsoo Kim
2015-10-15  2:05   ` Sergey Senozhatsky
2015-10-15  2:48     ` Joonsoo Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444808304-29320-9-git-send-email-iamjoonsoo.kim@lge.com \
    --to=js1304@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=smueller@chronox.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®