Hi all, in the past we had various discussions that doing the blk-crypto fallback below the block layer causes all kinds of problems due to very late splitting and communicating up features.
This series turns that call chain upside down by requiring the caller to call into blk-crypto using a new submit_bio wrapper instead so that only hardware encryption bios are passed through the block layer as such. While doings this I also noticed that the existing blk-crypto-fallback code does various unprotected memory allocations which this converts to mempools, or from loops of mempool allocations to the new safe batch mempool allocator. There might be future avenues for optimization by using high order folio allocations that match the file systems preferred folio size, but for that'd probably want a batch folio allocator first, in addition to deferring it to avoid scope creep. Changes since v1: - drop the mempool bulk allocator that was merged upstream - keep call bio_crypt_check_alignment for the hardware crypto case - rework the way bios are submitted earlier and reorder the series a bit to suit this - use struct initializers for struct fscrypt_zero_done in fscrypt_zeroout_range_inline_crypt - use cmpxchg to make the bi_status update in blk_crypto_fallback_encrypt_endio safe - rename the bio_set matching it's new purpose - remove usage of DECLARE_CRYPTO_WAIT() - use consistent GFP flags / scope - optimize data unit alignment checking - update Documentation/block/inline-encryption.rst for the new blk_crypto_submit_bio API - optimize alignment checking and ensure it still happens for hardware encryption - reorder the series a bit - improve various comments Diffstat: Documentation/block/inline-encryption.rst | 6 block/blk-core.c | 10 block/blk-crypto-fallback.c | 424 ++++++++++++++---------------- block/blk-crypto-internal.h | 30 -- block/blk-crypto.c | 78 +---- block/blk-map.c | 2 block/blk-merge.c | 19 - fs/btrfs/bio.c | 2 fs/buffer.c | 3 fs/crypto/bio.c | 91 +++--- fs/ext4/page-io.c | 3 fs/ext4/readpage.c | 9 fs/f2fs/data.c | 4 fs/f2fs/file.c | 3 fs/iomap/direct-io.c | 3 fs/iomap/ioend.c | 2 fs/xfs/xfs_zone_gc.c | 2 include/linux/bio.h | 2 include/linux/blk-crypto.h | 22 + include/linux/blkdev.h | 7 20 files changed, 367 insertions(+), 355 deletions(-)
