]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
blk-crypto: optimize data unit alignment checking
authorChristoph Hellwig <hch@lst.de>
Fri, 9 Jan 2026 06:07:48 +0000 (07:07 +0100)
committerJens Axboe <axboe@kernel.dk>
Sun, 11 Jan 2026 19:55:41 +0000 (12:55 -0700)
commit66e5a11d2ed6d58006d5cd8276de28751daaa230
treeaed43f96d0af5f27eae56a2ecac33e21c5238e62
parent3d939695e68218d420be2b5dbb2fa39ccb7e97ed
blk-crypto: optimize data unit alignment checking

Avoid the relatively high overhead of constructing and walking per-page
segment bio_vecs for data unit alignment checking by merging the checks
into existing loops.

For hardware support crypto, perform the check in bio_split_io_at, which
already contains a similar alignment check applied for all I/O.  This
means bio-based drivers that do not call bio_split_to_limits, should they
ever grow blk-crypto support, need to implement the check themselves,
just like all other queue limits checks.

For blk-crypto-fallback do it in the encryption/decryption loops.  This
means alignment errors for decryption will only be detected after I/O
has completed, but that seems like a worthwhile trade off.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-crypto-fallback.c
block/blk-crypto.c
block/blk-merge.c