[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200227182543.GC877@sol.localdomain>
Date: Thu, 27 Feb 2020 10:25:43 -0800
From: Eric Biggers <ebiggers@...nel.org>
To: Christoph Hellwig <hch@...radead.org>
Cc: Satya Tangirala <satyat@...gle.com>, linux-block@...r.kernel.org,
linux-scsi@...r.kernel.org, linux-fscrypt@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, linux-ext4@...r.kernel.org,
Barani Muthukumaran <bmuthuku@....qualcomm.com>,
Kuohong Wang <kuohong.wang@...iatek.com>,
Kim Boojin <boojin.kim@...sung.com>
Subject: Re: [PATCH v7 2/9] block: Inline encryption support for blk-mq
On Fri, Feb 21, 2020 at 09:22:05AM -0800, Christoph Hellwig wrote:
> > +int blk_crypto_evict_key(struct request_queue *q,
> > + const struct blk_crypto_key *key)
> > +{
> > + if (q->ksm && blk_ksm_crypto_mode_supported(q->ksm, key))
> > + return blk_ksm_evict_key(q->ksm, key);
> > +
> > + return 0;
> > +}
>
> Is there any point in this wrapper that just has a single caller?
> Als why doesn't blk_ksm_evict_key have the blk_ksm_crypto_mode_supported
> sanity check itself?
Later in the series it's changed to:
int blk_crypto_evict_key(struct request_queue *q,
const struct blk_crypto_key *key)
{
if (q->ksm && blk_ksm_crypto_mode_supported(q->ksm, key))
return blk_ksm_evict_key(q->ksm, key);
return blk_crypto_fallback_evict_key(key);
}
I.e. if the encryption mode is using hardware, then the key needs to be evicted
from q->ksm. Otherwise the key needs to be evicted from the fallback.
Also keep in mind that our goal is to define a clean API for any user of the
block layer to use encryption, not just fs/crypto/. That API includes:
blk_crypto_init_key()
blk_crypto_start_using_key()
bio_crypt_set_ctx()
blk_crypto_evict_key()
If anyone else decides to use inline encryption (e.g., if inline encryption
support were added to dm-crypt or another device-mapper target), they'll use
these same functions.
So IMO it's important to define a clean API that won't need to be refactored as
soon as anyone else starts using it, and not e.g. micro-optimize for code length
based on there currently being only one user.
- Eric
Powered by blists - more mailing lists