]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
dm-verity: move dm_verity_fec_io to mempool
authorEric Biggers <ebiggers@kernel.org>
Fri, 19 Dec 2025 19:29:03 +0000 (11:29 -0800)
committerMikulas Patocka <mpatocka@redhat.com>
Sun, 4 Jan 2026 19:35:32 +0000 (20:35 +0100)
commitb140a921eadfeaf48238a3a6d2da2a5e6946a31b
tree5ce590d896d5d75bbbb50d401b7d7f2607255e98
parenta23cc8257ecdfdeb25fd26d25fec4539ef377944
dm-verity: move dm_verity_fec_io to mempool

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.

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-verity-fec.c
drivers/md/dm-verity-fec.h
drivers/md/dm-verity.h