]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
blk-integrity: support arbitrary buffer alignment
authorKeith Busch <kbusch@kernel.org>
Fri, 13 Mar 2026 14:47:00 +0000 (07:47 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 14 Mar 2026 13:44:30 +0000 (07:44 -0600)
commit203247c5cb972af5d46bdb7d41ef40078048810b
tree67a4cfb8b6db0277baca6e3853cd57bc024f1f94
parent3dbaacf6ab68f81e3375fe769a2ecdbd3ce386fd
blk-integrity: support arbitrary buffer alignment

A bio segment may have partial interval block data with the rest
continuing into the next segments because direct-io data payloads only
need to align in memory to the device's DMA limits.

At the same time, the protection information may also be split in
multiple segments. The most likely way that may happen is if two
requests merge, or if we're directly using the io_uring user metadata.
The generate/verify, however, only ever accessed the first bip_vec.

Further, it may be possible to unalign the protection fields from the
user space buffer, or if there are odd additional opaque bytes in front
or in back of the protection information metadata region.

Change up the iteration to allow spanning multiple segments. This patch
is mostly a re-write of the protection information handling to allow any
arbitrary alignments, so it's probably easier to review the end result
rather than the diff.

Many controllers are not able to handle interval data composed of
multiple segments when PI is used, so this patch introduces a new
integrity limit that a low level driver can set to notify that it is
capable, default to false. The nvme driver is the first one to enable it
in this patch. Everyone else will force DMA alignment to the logical
block size as before to ensure interval data is always aligned within a
single segment.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Link: https://patch.msgid.link/20260313144701.1221652-2-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-settings.c
block/t10-pi.c
drivers/nvme/host/core.c
include/linux/blk-integrity.h