[RFC PATCH 0/2] Avoid software ref tag remapping for NVMe devices
From: Caleb Sander Mateos
Date: Sat Jun 27 2026 - 02:19:46 EST
Currently, each bio has a reference tag seed which is used to generate
the sequential ref tags in its protection information. In principle, the
ref tag seed can be any value as long as the same value is used when
blocks are written as when they are read back. However, some devices
(e.g. T10 DIF) require the ref tags to match the low bits of the
absolute integrity interval numbers. So the block integrity layer always
"remaps" ref tags to absolute integrity intervals using
blk_integrity_prepare() on writes and blk_integrity_complete() on reads.
On devices which do support an explicit "expected initial reference tag"
field in addition to the logical block address on each I/O, the software
ref tag remapping could be skipped by just passing the ref tag seed as
the expected initial ref tag.
Introduce a BLK_EXPECTED_REF_TAG_CAPABLE flag for devices to advertise
support for an expected initial ref tag. On devices that set this flag,
skip the block integrity layer ref tag remapping. Also take care not to
merge bios with non-contiguous ref tags, as the merged bio's ref tags
would no longer come from a single ref tag seed.
Set BLK_EXPECTED_REF_TAG_CAPABLE for NVMe devices and plumb the ref tag
seed (if provided) to the NVMe Read/Write (E)ILBRT field.
One potential concern would be NVMe devices which already have ref tags
written by an old kernel, which did perform the remapping (persisting
ref tags set to the low bits of the LBAs). When a new kernel that skips
the remapping reads back the ref tags, it would expect them to match the
ref tag seed, which would fail the ref tag verification.
Caleb Sander Mateos (2):
blk-integrity: add BLK_EXPECTED_REF_TAG_CAPABLE
nvme/core: advertise BLK_EXPECTED_REF_TAG_CAPABLE
block/blk-integrity.c | 18 ++++++++++++++++++
block/t10-pi.c | 3 ++-
drivers/nvme/host/core.c | 20 ++++++++++----------
include/linux/blk-integrity.h | 2 ++
include/linux/t10-pi.h | 5 -----
5 files changed, 32 insertions(+), 16 deletions(-)
--
2.54.0