From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Ignat Korchagin <ignat@cloudflare.com>,
"snitzer@redhat.com" <snitzer@redhat.com>,
"kernel-team@cloudflare.com" <kernel-team@cloudflare.com>,
"dm-crypt@saout.de" <dm-crypt@saout.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"dm-devel@redhat.com" <dm-devel@redhat.com>,
"agk@redhat.com" <agk@redhat.com>
Subject: Re: [dm-devel] [dm-crypt] [RFC PATCH 1/1] Add DM_CRYPT_FORCE_INLINE flag to dm-crypt target
Date: Wed, 24 Jun 2020 06:46:33 +0000 [thread overview]
Message-ID: <CY4PR04MB375103F66A8064B0EAF8946BE7950@CY4PR04MB3751.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20200624052739.GC844@sol.localdomain
On 2020/06/24 14:27, Eric Biggers wrote:
> On Wed, Jun 24, 2020 at 05:21:24AM +0000, Damien Le Moal wrote:
>>>> @@ -1458,13 +1459,18 @@ static void crypt_alloc_req_skcipher(struct crypt_config *cc,
>>>>
>>>> skcipher_request_set_tfm(ctx->r.req, cc->cipher_tfm.tfms[key_index]);
>>>>
>>>> - /*
>>>> - * Use REQ_MAY_BACKLOG so a cipher driver internally backlogs
>>>> - * requests if driver request queue is full.
>>>> - */
>>>> - skcipher_request_set_callback(ctx->r.req,
>>>> - CRYPTO_TFM_REQ_MAY_BACKLOG,
>>>> - kcryptd_async_done, dmreq_of_req(cc, ctx->r.req));
>>>> + if (test_bit(DM_CRYPT_FORCE_INLINE, &cc->flags))
>>>> + /* make sure we zero important fields of the request */
>>>> + skcipher_request_set_callback(ctx->r.req,
>>>> + 0, NULL, NULL);
>>>> + else
>>>> + /*
>>>> + * Use REQ_MAY_BACKLOG so a cipher driver internally backlogs
>>>> + * requests if driver request queue is full.
>>>> + */
>>>> + skcipher_request_set_callback(ctx->r.req,
>>>> + CRYPTO_TFM_REQ_MAY_BACKLOG,
>>>> + kcryptd_async_done, dmreq_of_req(cc, ctx->r.req));
>>>> }
>>>
>>> This looks wrong. Unless type=0 and mask=CRYPTO_ALG_ASYNC are passed to
>>> crypto_alloc_skcipher(), the skcipher implementation can still be asynchronous,
>>> in which case providing a callback is required.
>>>
>>> Do you intend that the "force_inline" option forces the use of a synchronous
>>> skcipher (alongside the other things it does)? Or should it still allow
>>> asynchronous ones?
>>>
>>> We may not actually have a choice in that matter, since xts-aes-aesni has the
>>> CRYPTO_ALG_ASYNC bit set (as I mentioned) despite being synchronous in most
>>> cases; thus, the crypto API won't give you it if you ask for a synchronous
>>> cipher. So I think you still need to allow async skciphers? That means a
>>> callback is still always required.
>>
>> Arg... So it means that some skciphers will not be OK at all for SMR writes. I
>> was not aware of these differences (tested with aes-xts-plain64 only). The ugly
>> way to support async ciphers would be to just wait inline for the crypto API to
>> complete using a completion for instance. But that is very ugly. Back to
>> brainstorming, and need to learn more about the crypto API...
>>
>
> It's easy to wait for crypto API requests to complete if you need to --
> just use crypto_wait_req().
OK. Thanks for the information. I will look into this and the performance
implications. A quick grep shows that a lot of different accelerators for
different architectures have CRYPTO_ALG_ASYNC set. So definitely something that
needs to be checked for SMR, and for Ignat inline patch.
> We do this in fs/crypto/, for example. (Not many people are using fscrypt with
> crypto API based accelerators, so there hasn't yet been much need to support the
> complexity of issuing multiple async crypto requests like dm-crypt supports.)
Zonefs fscrypt support is on my to do list too :)
Thanks !
>
> - Eric
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2020-06-24 6:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 16:41 [RFC PATCH 0/1] dm-crypt excessive overhead Ignat Korchagin
2020-06-19 16:41 ` [RFC PATCH 1/1] Add DM_CRYPT_FORCE_INLINE flag to dm-crypt target Ignat Korchagin
2020-06-24 5:04 ` [dm-crypt] " Eric Biggers
2020-06-24 5:21 ` [dm-devel] " Damien Le Moal
2020-06-24 5:27 ` Eric Biggers
2020-06-24 6:46 ` Damien Le Moal [this message]
2020-06-24 7:24 ` Damien Le Moal
2020-06-24 7:49 ` Damien Le Moal
2020-06-24 8:24 ` Ignat Korchagin
2020-06-24 16:24 ` Eric Biggers
2020-06-24 17:00 ` Ignat Korchagin
2020-06-24 5:12 ` [dm-devel] " Damien Le Moal
2020-06-19 16:55 ` [RFC PATCH 0/1] dm-crypt excessive overhead Mike Snitzer
2020-06-19 18:39 ` Mikulas Patocka
2020-06-19 19:44 ` Ignat Korchagin
2020-06-20 1:23 ` Herbert Xu
2020-06-20 19:36 ` Mikulas Patocka
2020-06-20 21:02 ` Ignat Korchagin
2020-06-23 15:33 ` Mike Snitzer
2020-06-23 16:24 ` Ignat Korchagin
2020-06-24 0:23 ` Herbert Xu
2020-06-22 0:45 ` [dm-devel] " Damien Le Moal
2020-06-22 7:55 ` Ignat Korchagin
2020-06-22 8:08 ` Damien Le Moal
2020-06-23 15:01 ` Mike Snitzer
2020-06-23 15:07 ` Ignat Korchagin
2020-06-23 15:22 ` Mike Snitzer
2020-06-24 4:54 ` [dm-devel] " Damien Le Moal
2020-06-24 5:22 ` Mike Snitzer
2020-06-24 8:02 ` Ignat Korchagin
2020-06-24 4:28 ` Damien Le Moal
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=CY4PR04MB375103F66A8064B0EAF8946BE7950@CY4PR04MB3751.namprd04.prod.outlook.com \
--to=damien.lemoal@wdc.com \
--cc=agk@redhat.com \
--cc=dm-crypt@saout.de \
--cc=dm-devel@redhat.com \
--cc=ebiggers@kernel.org \
--cc=ignat@cloudflare.com \
--cc=kernel-team@cloudflare.com \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@redhat.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).