Re: [PATCH v6 2/9] block: Add encryption context to struct bio

Eric Biggers
2019-12-18T22:27:30Z

On Wed, Dec 18, 2019 at 04:25:28PM -0500, Martin K. Petersen wrote:
>
> Darrick,
>
> >> +#ifdef CONFIG_BLK_INLINE_ENCRYPTION
> >> + struct bio_crypt_ctx *bi_crypt_context;
> >> +#endif
> >
> > This grows struct bio even if we aren't actively using bi_crypt_context,
> > and I thought Jens told us to stop making it bigger. :)
>
> Yeah. Why not use the bio integrity plumbing? It was explicitly designed
> to attach things to a bio and have them consumed by the device driver.
>

There's not really any such thing as "use the bio integrity plumbing".
blk-integrity just does blk-integrity; it's not a plumbing layer that allows
other features to be supported. Well, in theory we could refactor and rename
all the hooks to "blk-extra" and make them delegate to either blk-integrity or
blk-crypto, but I think that would be overkill.

What we could do, though, is say that at most one of blk-crypto and
blk-integrity can be used at once on a given bio, and put the bi_integrity and
bi_crypt_context pointers in union. (That would require allocating a
REQ_INLINECRYPT bit so that we can tell what the pointer points to.)

- Eric