linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	<linux-kernel@vger.kernel.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH 5/7] zram: use crypto api to check alg availability
Date: Fri, 27 May 2016 13:43:43 +0900	[thread overview]
Message-ID: <20160527044343.GE2322@bbox> (raw)
In-Reply-To: <20160525143006.1207-6-sergey.senozhatsky@gmail.com>

Hello Sergey,

I want to know more how it works so below questions goes.

On Wed, May 25, 2016 at 11:30:04PM +0900, Sergey Senozhatsky wrote:
> There is no way to get a string with all the crypto comp
> algorithms supported by the crypto comp engine, so we need
> to maintain our own backends list. At the same time we
> additionally need to use crypto_has_comp() to make sure
> that the user has requested a compression algorithm that is
> recognized by the crypto comp engine. Relying on /proc/crypto
> is not an options here, because it does not show not-yet-inserted
> compression modules.
> 
> Example:
> 
>  modprobe zram
>  cat /proc/crypto | grep -i lz4
>  modprobe lz4
>  cat /proc/crypto | grep -i lz4
> name         : lz4
> driver       : lz4-generic
> module       : lz4
> 
> So the user can't tell exactly if the lz4 is really supported
> from /proc/crypto output, unless someone or something has loaded
> it.
> 
> This patch also adds crypto_has_comp() to zcomp_available_show().

crypto_has_comp works regardless of that whether module is loading or not?
IOW, currently, if lz4 modules is not loading, but crypto_has_comp return
true about lz4 module.
Right?

> We store all the compression algorithms names in zcomp's `backends'
> array, regardless the CONFIG_CRYPTO_FOO configuration, but show

Then, you mean we should add new string into backend array whenever
adding new crypto compatible compression algorithm?

> only those that are also supported by crypto engine. This helps
> user to know the exact list of compression algorithms that can be
> used.
> 
> Example:
>   module lz4 is not loaded yet, but is supported by the crypto
>   engine. /proc/crypto has no information on this module, while
>   zram's `comp_algorithm' lists it:
> 
>  cat /proc/crypto | grep -i lz4
> 
>  cat /sys/block/zram0/comp_algorithm
> [lzo] lz4 deflate lz4hc 842

So, when lzo module is loading?

> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> Cc: Minchan Kim <minchan@kernel.org>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
>  drivers/block/zram/zcomp.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> index 79b30d7..a8593e9 100644
> --- a/drivers/block/zram/zcomp.c
> +++ b/drivers/block/zram/zcomp.c
> @@ -29,12 +29,16 @@ static const char * const backends[] = {
>  static const char *find_backend(const char *compress)
>  {
>  	int i = 0;
> +
>  	while (backends[i]) {
>  		if (sysfs_streq(compress, backends[i]))
>  			break;
>  		i++;
>  	}
> -	return backends[i];
> +
> +	if (backends[i] && crypto_has_comp(backends[i], 0, 0))
> +		return backends[i];
> +	return NULL;
>  }
>  
>  static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
> @@ -74,14 +78,16 @@ ssize_t zcomp_available_show(const char *comp, char *buf)
>  	ssize_t sz = 0;
>  	int i = 0;
>  
> -	while (backends[i]) {
> +	for (; backends[i]; 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]);
>  		else
>  			sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
>  					"%s ", backends[i]);
> -		i++;
>  	}
>  	sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
>  	return sz;
> -- 
> 2.8.3.394.g3916adf
> 

  reply	other threads:[~2016-05-27  4:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 14:29 [PATCH 0/7] zram: switch to crypto api Sergey Senozhatsky
2016-05-25 14:30 ` [PATCH 1/7] zram: rename zstrm find-release functions Sergey Senozhatsky
2016-05-26  0:44   ` Minchan Kim
2016-05-26  1:07     ` Sergey Senozhatsky
2016-05-25 14:30 ` [PATCH 2/7] zram: switch to crypto compress API Sergey Senozhatsky
2016-05-27  4:22   ` Minchan Kim
2016-05-27  7:59     ` Sergey Senozhatsky
2016-05-25 14:30 ` [PATCH 3/7] zram: drop zcomp param from compress/decompress Sergey Senozhatsky
2016-05-27  4:22   ` Minchan Kim
2016-05-27  7:31     ` Sergey Senozhatsky
2016-05-25 14:30 ` [PATCH 4/7] zram: align zcomp interface to crypto comp API Sergey Senozhatsky
2016-05-27  4:31   ` Minchan Kim
2016-05-27  8:00     ` Sergey Senozhatsky
2016-05-25 14:30 ` [PATCH 5/7] zram: use crypto api to check alg availability Sergey Senozhatsky
2016-05-27  4:43   ` Minchan Kim [this message]
2016-05-27  7:50     ` Sergey Senozhatsky
2016-05-27  8:27       ` Minchan Kim
2016-05-27  8:43         ` Herbert Xu
2016-05-27  9:04           ` Minchan Kim
2016-05-29  3:24             ` Sergey Senozhatsky
2016-05-30  4:47               ` Minchan Kim
2016-05-30  4:57                 ` Sergey Senozhatsky
2016-05-25 14:30 ` [PATCH 6/7] zram: delete custom lzo/lz4 Sergey Senozhatsky
2016-05-25 14:30 ` [PATCH 7/7] zram: add more compression algorithms Sergey Senozhatsky
2016-05-26  0:43 ` [PATCH 0/7] zram: switch to crypto api Joonsoo Kim
2016-05-26  1:12   ` Sergey Senozhatsky
2016-05-26  1:52     ` Joonsoo Kim
2016-05-26  0:52 ` Minchan Kim
2016-05-26  1:08   ` Sergey Senozhatsky

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=20160527044343.GE2322@bbox \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).