block for-7.1/integrity rebase for mem alignment
Subsystems (3)
v8 cover block for-7.1/integrity rebase for mem alignment
From: Keith Busch <[email protected]>
This is the rebased version of the flexible t10 alignment feature on top of block's for-7.1/block-integrity branch to apply atop Christoph's fs-integrity:
https://lore.kernel.org/linux-block/[email protected]/
The only change from the previous version is to incorporate the function name changes and verify's status code return type that were introduced in the file system integrity support patch set.
I've also included the ublk support for this feature since it was previously accepted and has a dependency on patch 1.
For reference, here is the resulting diff from the previous version's implementation before fs-integrity to this new one after fs support:
---
t10-pi.c renamed from t10-pi.c.orig +8 -7
@@ -304,7 +304,8 @@return ret; } -static void blk_integrity_iterate (struct bio *bio,struct bvec_iter *data_iter, +static blk_status_t blk_integrity_iterate (struct bio *bio, +struct bvec_iter *data_iter,bool verify) {struct blk_integrity *bi =blk_get_integrity (bio->bi_bdev->bd_disk);
@@ -342,11 +343,10 @@kunmap_local (kaddr); } -if (ret) - bio->bi_status = ret; +return ret; } -void blk_integrity_generate (struct bio *bio) +void bio_integrity_generate (struct bio *bio) {struct blk_integrity *bi =blk_get_integrity (bio->bi_bdev->bd_disk);
@@ -361,7 +361,7 @@ } } -void blk_integrity_verify_iter (struct bio *bio,struct bvec_iter *saved_iter) +blk_status_t bio_integrity_verify (struct bio *bio,struct bvec_iter *saved_iter) {struct blk_integrity *bi =blk_get_integrity (bio->bi_bdev->bd_disk);
@@ -369,11 +369,12 @@case BLK_INTEGRITY_CSUM_CRC64 :case BLK_INTEGRITY_CSUM_CRC :case BLK_INTEGRITY_CSUM_IP : -blk_integrity_iterate (bio, saved_iter, true); -break ; +return blk_integrity_iterate (bio, saved_iter, true);default :break ; } + +return BLK_STS_OK ; }/*
--
Caleb Sander Mateos (1):
ublk: report BLK_SPLIT_INTERVAL_CAPABLE
Keith Busch (1):
blk-integrity: support arbitrary buffer alignment
block/blk-settings.c | 12 +- block/t10-pi.c | 816 +++++++++++++++++++--------------- drivers/block/ublk_drv.c | 2 +- drivers/nvme/host/core.c | 1 + include/linux/blk-integrity.h | 1 + 5 files changed, 466 insertions(+), 366 deletions(-)
Signature · 1 line
2.52.0
PATCH v8 1/2 blk-integrity: support arbitrary buffer alignment
From: Keith Busch <[email protected]>
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.
--- block/blk-settings.c | 12 +- block/t10-pi.c | 816 +++++++++++++++++++--------------- drivers/nvme/host/core.c | 1 + include/linux/blk-integrity.h | 1 + 4 files changed, 465 insertions(+), 365 deletions(-)
block/blk-settings.c +8 -4
@@ -189,11 +189,11 @@ static int blk_validate_integrity_limits(struct queue_limits *lim) }/* -* The PI generation / validation helpers do not expect intervals to -* straddle multiple bio_vecs. Enforce alignment so that those are +* Some IO controllers can not handle data intervals straddling +* multiple bio_vecs. For those, enforce alignment so that those are * never generated, and that each buffer is aligned as expected. */ -if (bi->csum_type) { +if (!(bi->flags &BLK_SPLIT_INTERVAL_CAPABLE ) && bi->csum_type) { lim->dma_alignment =max (lim->dma_alignment, (1U << bi->interval_exp) -1 ); }
@@ -992,10 +992,14 @@ bool queue_limits_stack_integrity(struct queue_limits *t,if ((ti->flags &BLK_INTEGRITY_REF_TAG ) != (bi->flags &BLK_INTEGRITY_REF_TAG )) goto incompatible; +if ((ti->flags &BLK_SPLIT_INTERVAL_CAPABLE ) && + !(bi->flags &BLK_SPLIT_INTERVAL_CAPABLE )) + ti->flags &= ~BLK_SPLIT_INTERVAL_CAPABLE ; }else { ti->flags =BLK_INTEGRITY_STACKED ; ti->flags |= (bi->flags &BLK_INTEGRITY_DEVICE_CAPABLE ) | - (bi->flags &BLK_INTEGRITY_REF_TAG ); + (bi->flags &BLK_INTEGRITY_REF_TAG ) | + (bi->flags &BLK_SPLIT_INTERVAL_CAPABLE ); ti->csum_type = bi->csum_type; ti->pi_tuple_size = bi->pi_tuple_size; ti->metadata_size = bi->metadata_size;
block/t10-pi.c +455 -361
917 lines not on this page · raw message
drivers/nvme/host/core.c +1 -0
@@ -1875,6 +1875,7 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,break ; } + bi->flags |=BLK_SPLIT_INTERVAL_CAPABLE ; bi->metadata_size = head->ms;if (bi->csum_type) { bi->pi_tuple_size = head->pi_size;
include/linux/blk-integrity.h +1 -0
@@ -14,6 +14,7 @@ enum blk_integrity_flags {BLK_INTEGRITY_DEVICE_CAPABLE =1 <<2 ,BLK_INTEGRITY_REF_TAG =1 <<3 ,BLK_INTEGRITY_STACKED =1 <<4 , + BLK_SPLIT_INTERVAL_CAPABLE = 1 << 5, };const char *blk_integrity_profile_name (struct blk_integrity *bi);
Signature · 1 line
2.52.0
PATCH v8 2/2 ublk: report BLK_SPLIT_INTERVAL_CAPABLE
In reply to Keith BuschFrom: Caleb Sander Mateos <[email protected]>
The ublk driver doesn't access request integrity buffers directly, it only copies them to/from the ublk server in ublk_copy_user_integrity(). ublk_copy_user_integrity() uses bio_for_each_integrity_vec() to walk all the integrity segments. ublk devices are therefore capable of handling requests with integrity intervals split across segments. Set BLK_SPLIT_INTERVAL_CAPABLE in the struct blk_integrity flags for ublk devices to opt out of the integrity-interval dma_alignment limit.
--- drivers/block/ublk_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/ublk_drv.c +1 -1
@@ -808,7 +808,7 @@ static void ublk_dev_param_basic_apply(struct ublk_device *ub)static int ublk_integrity_flags (u32 flags) { -int ret_flags =0 ; +int ret_flags =BLK_SPLIT_INTERVAL_CAPABLE ;if (flags &LBMD_PI_CAP_INTEGRITY ) { flags &= ~LBMD_PI_CAP_INTEGRITY ;
Signature · 1 line
2.52.0
Quoted 11 lines · Keith Busch
This is the rebased version of the flexible t10 alignment feature on top of block's for-7.1/block-integrity branch to apply atop Christoph's fs-integrity:
https://lore.kernel.org/linux-block/[email protected]/
The only change from the previous version is to incorporate the function name changes and verify's status code return type that were introduced in the file system integrity support patch set.
[...]
Applied, thanks!
[0/2] block for-7.1/integrity rebase for mem alignment
(no commit info)
[1/2] blk-integrity: support arbitrary buffer alignment
(no commit info)
[2/2] ublk: report BLK_SPLIT_INTERVAL_CAPABLE
(no commit info)
Best regards,
Signature · 1 line
Jens Axboe
Keith Busch
maintainerQuoted 7 lines · Jens Axboe
Quoted 6 lines · Keith Busch
This is the rebased version of the flexible t10 alignment feature on top of block's for-7.1/block-integrity branch to apply atop Christoph's fs-integrity:
Quoted 7 lines
Quoted 5 lines
The only change from the previous version is to incorporate the function name changes and verify's status code return type that were introduced in the file system integrity support patch set.
[...]
Applied, thanks!
Did you forget to 'git push' this branch?
Jens Axboe
maintainerQuoted 12 lines · Keith Busch
Quoted 11 lines · Jens Axboe
Quoted 10 lines · Keith Busch
This is the rebased version of the flexible t10 alignment feature on top of block's for-7.1/block-integrity branch to apply atop Christoph's fs-integrity:
https://lore.kernel.org/linux-block/[email protected]/
The only change from the previous version is to incorporate the function name changes and verify's status code return type that were introduced in the file system integrity support patch set.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
[...]
Applied, thanks!
Did you forget to 'git push' this branch?
I don't think so?
commit 203247c5cb972af5d46bdb7d41ef40078048810b
Author: Keith Busch <[email protected]> AuthorDate: Fri Mar 13 07:47:00 2026 -0700 Commit: Jens Axboe <[email protected]> CommitDate: Sat Mar 14 07:44:30 2026 -0600
blk-integrity: support arbitrary buffer alignment
and
commit 5d540162059598c3f79e12f96064825cc91f0f9c
Author: Caleb Sander Mateos <[email protected]> AuthorDate: Fri Mar 13 07:47:01 2026 -0700 Commit: Jens Axboe <[email protected]> CommitDate: Sat Mar 14 07:44:30 2026 -0600
ublk: report BLK_SPLIT_INTERVAL_CAPABLE
in the tree since 9 days ago?
Signature · 1 line
Jens Axboe
Keith Busch
maintainerQuoted 16 lines · Jens Axboe
Quoted 1 line · Keith Busch
Did you forget to 'git push' this branch?
I don't think so?
commit
203247c5cb972af5d46bdb7d41ef40078048810bAuthor: Keith Busch <[email protected]> AuthorDate: Fri Mar 13 07:47:00 2026 -0700 Commit: Jens Axboe <[email protected]> CommitDate: Sat Mar 14 07:44:30 2026 -0600blk-integrity: support arbitrary buffer alignment
and
commit
5d540162059598c3f79e12f96064825cc91f0f9c
Quoted 8 lines
Author: Caleb Sander Mateos <[email protected]> AuthorDate: Fri Mar 13 07:47:01 2026 -0700 Commit: Jens Axboe <[email protected]> CommitDate: Sat Mar 14 07:44:30 2026 -0600ublk: report
BLK_SPLIT_INTERVAL_CAPABLEin the tree since 9 days ago?
The current gitweb doesn't show it:
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git/log/?h=for-7.1/block-integrity
And I don't find it in the repo either:
$ git fetch block $ git log block/for-7.1/block-integrity -n 1
commit a9aa6045abde87b94168c3ba034b953417e27272 (block/for-7.1/block-integrity)
Author: Christoph Hellwig <[email protected]>
Date: Mon Feb 23 05:20:07 2026 -0800
block: pass a maxlen argument to bio_iov_iter_bounce
Jens Axboe
maintainerQuoted 32 lines · Keith Busch
Quoted 16 lines · Jens Axboe
Quoted 1 line · Keith Busch
Did you forget to 'git push' this branch?
I don't think so?
commit
203247c5cb972af5d46bdb7d41ef40078048810bAuthor: Keith Busch <[email protected]> AuthorDate: Fri Mar 13 07:47:00 2026 -0700 Commit: Jens Axboe <[email protected]> CommitDate: Sat Mar 14 07:44:30 2026 -0600blk-integrity: support arbitrary buffer alignment
and
commit
5d540162059598c3f79e12f96064825cc91f0f9cQuoted 8 lines
Author: Caleb Sander Mateos <[email protected]> AuthorDate: Fri Mar 13 07:47:01 2026 -0700 Commit: Jens Axboe <[email protected]> CommitDate: Sat Mar 14 07:44:30 2026 -0600ublk: report
BLK_SPLIT_INTERVAL_CAPABLEin the tree since 9 days ago?
The current gitweb doesn't show it:
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git/log/?h=for-7.1/block-integrity
And I don't find it in the repo either:
Quoted 8 lines
$ git fetch block $ git log block/for-7.1/block-integrity -n 1commit
a9aa6045abde87b94168c3ba034b953417e27272(block/for-7.1/block-integrity)
Author: Christoph Hellwig <[email protected]>
Date: Mon Feb 23 05:20:07 2026 -0800block: pass a maxlen argument to
bio_iov_iter_bounce
You're looking in the wrong place. It's not in that branch, that branch only exists to have a merge point with the VFS. If you check my for-next branch you'll see it, and it's in for-7.1/block as well (that's the origin).
Signature · 1 line
Jens Axboe
Keith Busch
maintainerQuoted 5 lines · Jens Axboe
You're looking in the wrong place. It's not in that branch, that branch only exists to have a merge point with the VFS. If you check my for-next branch you'll see it, and it's in for-7.1/block as well (that's the origin).
Oh my bad. My local branch was pointing at the vfs one from the rebase, and I assumed that was the destination. I'm making new stuff on top and was confused about the divergence. Thanks, and sorry for the noise.
Jens Axboe
maintainerQuoted 10 lines · Keith Busch
Quoted 5 lines · Jens Axboe
You're looking in the wrong place. It's not in that branch, that branch only exists to have a merge point with the VFS. If you check my for-next branch you'll see it, and it's in for-7.1/block as well (that's the origin).
Oh my bad. My local branch was pointing at the vfs one from the rebase, and I assumed that was the destination. I'm making new stuff on top and was confused about the divergence. Thanks, and sorry for the noise.
And let's please fix that nvme list link too!
Signature · 1 line
Jens Axboe