Message ID | 20210325212609.492188-1-satyat@google.com (mailing list archive) |
---|---|
Headers | show |
Series | ensure bios aren't split in middle of crypto data unit | expand |
On 3/25/21 2:26 PM, Satya Tangirala wrote: > When a bio has an encryption context, its size must be aligned to its > crypto data unit size. A bio must not be split in the middle of a data > unit. Currently, bios are split at logical block boundaries [...] Hi Satya, Are you sure that the block layer core splits bios at logical block boundaries? Commit 9cc5169cd478 ("block: Improve physical block alignment of split bios") should have changed the behavior from splitting at logical block boundaries into splitting at physical block boundaries. Without having looked at this patch series, can the same effect be achieved by reporting the crypto data unit size as the physical block size? Thanks, Bart.
On Thu, Mar 25, 2021 at 02:51:31PM -0700, Bart Van Assche wrote: > On 3/25/21 2:26 PM, Satya Tangirala wrote: > > When a bio has an encryption context, its size must be aligned to its > > crypto data unit size. A bio must not be split in the middle of a data > > unit. Currently, bios are split at logical block boundaries [...] > > Hi Satya, > > Are you sure that the block layer core splits bios at logical block > boundaries? Commit 9cc5169cd478 ("block: Improve physical block > alignment of split bios") should have changed the behavior from > splitting at logical block boundaries into splitting at physical block > boundaries. Ah, what I really meant with that sentence was "Currently, if a bio is split, the size of the resulting bio is guaranteed to be aligned to a the lbs. The endpoint of the bio might also be aligned to a physical block boundary (which 9cc5169cd478 tries to achieve if possible), but the bio's size (and hence also its endpoint since the start of the bio is always lbs aligned) is *at least* lbs aligned". Does that sound accurate? With inline encryption, that lbs alignment guarantee is no longer enough - the bio now needs to have a size that's aligned to the bio's data unit size (which may be larger than the logical block size, but is also still a power of 2). > Without having looked at this patch series, can the same > effect be achieved by reporting the crypto data unit size as the > physical block size? That would've been awesome, but I don't think we can do that :( 1) There isn't only one crypto data unit size. A device can support, and upper layers are free to use, many different data unit sizes. 2) IIUC 9cc5169cd478 (or more accurately get_max_io_size() since the function has been changed slightly since your original patch) doesn't align the size of the bio to the pbs - it only aligns the endpoint of the bio to the pbs (and it may actually not even do that if it turns out to not be possible). Is that right? If so, that means that if the startpoint of the bio isn't pbs aligned, the size of the bio won't be pbs aligned either. > > Thanks, > > Bart.
On 3/25/21 6:39 PM, Satya Tangirala wrote: > On Thu, Mar 25, 2021 at 02:51:31PM -0700, Bart Van Assche wrote: >> Are you sure that the block layer core splits bios at logical block >> boundaries? Commit 9cc5169cd478 ("block: Improve physical block >> alignment of split bios") should have changed the behavior from >> splitting at logical block boundaries into splitting at physical block >> boundaries. > > Ah, what I really meant with that sentence was "Currently, if a bio is > split, the size of the resulting bio is guaranteed to be aligned to a > the lbs. The endpoint of the bio might also be aligned to a physical > block boundary (which 9cc5169cd478 tries to achieve if possible), but > the bio's size (and hence also its endpoint since the start of the bio > is always lbs aligned) is *at least* lbs aligned". Does that sound > accurate? That sounds better to me :-) >> Without having looked at this patch series, can the same >> effect be achieved by reporting the crypto data unit size as the >> physical block size? > > That would've been awesome, but I don't think we can do that :( > 1) There isn't only one crypto data unit size. A device can support, > and upper layers are free to use, many different data unit sizes. > 2) IIUC 9cc5169cd478 (or more accurately get_max_io_size() since the > function has been changed slightly since your original patch) > doesn't align the size of the bio to the pbs - it only aligns the > endpoint of the bio to the pbs (and it may actually not even do > that if it turns out to not be possible). Is that right? If so, > that means that if the startpoint of the bio isn't pbs aligned, the > size of the bio won't be pbs aligned either. Hmm ... if the start of a bio is not aligned to the physical block size I don't think that the block layer can do anything about the start of the bio. Anyway, I have taken a quick look at this patch series and the patch series looks pretty clean to me. I will let Christoph review this patch series since he already reviewed the previous version of this series. Bart.
On Thu, Mar 25, 2021 at 08:46:20PM -0700, Bart Van Assche wrote: > On 3/25/21 6:39 PM, Satya Tangirala wrote: > > On Thu, Mar 25, 2021 at 02:51:31PM -0700, Bart Van Assche wrote: > >> Are you sure that the block layer core splits bios at logical block > >> boundaries? Commit 9cc5169cd478 ("block: Improve physical block > >> alignment of split bios") should have changed the behavior from > >> splitting at logical block boundaries into splitting at physical block > >> boundaries. > > > > Ah, what I really meant with that sentence was "Currently, if a bio is > > split, the size of the resulting bio is guaranteed to be aligned to a > > the lbs. The endpoint of the bio might also be aligned to a physical > > block boundary (which 9cc5169cd478 tries to achieve if possible), but > > the bio's size (and hence also its endpoint since the start of the bio > > is always lbs aligned) is *at least* lbs aligned". Does that sound > > accurate? > That sounds better to me :-) > > >> Without having looked at this patch series, can the same > >> effect be achieved by reporting the crypto data unit size as the > >> physical block size? > > > > That would've been awesome, but I don't think we can do that :( > > 1) There isn't only one crypto data unit size. A device can support, > > and upper layers are free to use, many different data unit sizes. > > 2) IIUC 9cc5169cd478 (or more accurately get_max_io_size() since the > > function has been changed slightly since your original patch) > > doesn't align the size of the bio to the pbs - it only aligns the > > endpoint of the bio to the pbs (and it may actually not even do > > that if it turns out to not be possible). Is that right? If so, > > that means that if the startpoint of the bio isn't pbs aligned, the > > size of the bio won't be pbs aligned either. > > Hmm ... if the start of a bio is not aligned to the physical block size > I don't think that the block layer can do anything about the start of > the bio. Anyway, I have taken a quick look at this patch series and the > patch series looks pretty clean to me. I will let Christoph review this > patch series since he already reviewed the previous version of this series. Sounds good. Thanks for looking through the series! > > Bart.