[PATCH v3 0/6] block: fix integrity offset/length conversions

From: Caleb Sander Mateos

Date: Thu Apr 16 2026 - 21:58:24 EST


The block layer's integrity code currently sets the seed (initial
reference tag) in units of 512-byte sectors but increments it in units
of integrity intervals. Not only do the T10 DIF formats require ref tags
to be the lower bits of the logical block address, but mixing the two
units means the ref tags used for a particular logical block vary based
on its offset within a read/write request. This looks to be a
longstanding bug affecting block devices that support integrity with
block sizes > 512 bytes; I'm surprised it wasn't noticed before.

Also fix the newly added fs_bio_integrity_verify() to pass
bio_integrity_verify() a struct bdev_iter representing the data instead
of the integrity. Most of the integrity data is currently being skipped.

v3:
- Drop bi and bip arguments to bip_set_seed() (Christoph)

v2:
- Reorder fixes before refactoring commits
- Use u64, SECTOR_SHIFT (Christoph)
- Don't take sector_t in bip_set_seed() (Christoph)

Caleb Sander Mateos (6):
block: use integrity interval instead of sector as seed
bio-integrity-fs: pass data iter to bio_integrity_verify()
blk-integrity: take u64 in bio_integrity_intervals()
bio-integrity-fs: use integrity interval instead of sector as seed
t10-pi: use bio_integrity_intervals() helper
blk-integrity: avoid sector_t in bip_{get,set}_seed()

block/bio-integrity-fs.c | 8 ++++++--
block/bio-integrity.c | 4 ++--
block/t10-pi.c | 7 ++++---
drivers/nvme/target/io-cmd-bdev.c | 3 +--
drivers/target/target_core_iblock.c | 3 +--
include/linux/bio-integrity.h | 11 -----------
include/linux/blk-integrity.h | 27 ++++++++++++++++++++-------
include/linux/bvec.h | 1 +
8 files changed, 35 insertions(+), 29 deletions(-)

--
2.45.2