Re: [PATCH] block: Add block level changes for inline encryption
From: Jens Axboe <axboe@kernel.dk>
Date: 2018-06-01 17:30:59
Also in:
lkml
On 6/1/18 12:27 AM, Ladvine D Almeida wrote:
On Thursday 31 May 2018 04:46 PM, Jens Axboe wrote:quoted
On 5/31/18 1:47 AM, Ladvine D Almeida wrote:quoted
On Monday 28 May 2018 04:54 PM, Jens Axboe wrote:quoted
On 5/28/18 7:43 AM, Ladvine D Almeida wrote:quoted
This patch introduces new variable under bio structure to facilitate inline encryption. This variable is used to associate I/O requests to crypto information.Hard no on this, for two reasons: 1) Any additions to struct bio are scrutinized heavily and need strong justification.Thanks for sharing your feedback on the patch. I am providing reference to an earlier article related to inline encryption support below: https://urldefense.proofpoint.com/v2/url?u=https-3A__lwn.net_Articles_717754_&d=DwICaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=z00zRD9ARrwHpe-XSl1OtUp1uNKGYoXI1G2DhOaDDBI&m=m8U0bg9QiswO2oVJgJKq3MmJpqPPK_tN667XwsjojcM&s=9VPcl80YTKwbf8T-oCxWTRahYzS2xNDHZMexpFbuepY&e=Took a quick look, and this looks like a classic case of something that should just be a cloned bio. If you clone, you own the bi_private field, which is what you need.Cloning the bio gives ownership of the bi_private variable which i can use to refer to the crypto context. But i have the following problem here: 1. In the dm-crypt subsystem, we clone the bio and assign the bi_private variable. Afterwards, generic_make_request() is done to submit I/O request to block device. 2. The bio will be cloned further in the below layers. The reference in the bi_private variable is now lost as the bio_clone function will not copy the bi_private variable. Also, the bi_private variable is already used in the dm-crypt layer for storing its private data. This prevents me from using the same.
If you clone or allocate a bio, you are the owner of bi_private. If someone further down the stack clones it again, then they own the NEW bi_private of the newly returned cloned. Nobody will mess with yours, that would be a layering violation. That is the way to store data on a per bio basis, not by adding a new random field to the bio structure. -- Jens Axboe