On Tue, Dec 16, 2025 at 03:06:08PM -0800, Eric Biggers wrote: > Currently, struct dm_verity_fec_io is allocated in the front padding of > struct bio using dm_target::per_io_data_size. Unfortunately, struct > dm_verity_fec_io is very large: 3096 bytes when CONFIG_64BIT=y && > PAGE_SIZE == 4096, or 9240 bytes when CONFIG_64BIT=y && PAGE_SIZE == > 16384. This makes the bio size very large. > > Moreover, most of dm_verity_fec_io gets iterated over up to three times, > even on I/O requests that don't require any error correction: > > 1. To zero the memory on allocation, if init_on_alloc=1. (This happens > when the bio is allocated, not in dm-verity itself.) > > 2. To zero the buffers array in verity_fec_init_io(). > > 3. To free the buffers in verity_fec_finish_io(). > > Fix all of these inefficiencies by moving dm_verity_fec_io to a mempool. > Replace the embedded dm_verity_fec_io with a pointer > dm_verity_io::fec_io. verity_fec_init_io() initializes it to NULL, > verity_fec_decode() allocates it on the first call, and > verity_fec_finish_io() cleans it up. The normal case is that the > pointer simply stays NULL, so the overhead becomes negligible. > > Signed-off-by: Eric Biggers <[email protected]>
Reviewed-by: Sami Tolvanen <[email protected]> Sami
