Skip to content

blk-integrity: support arbitrary buffer alignment#588

Closed
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1056653=>linus-master
Closed

blk-integrity: support arbitrary buffer alignment#588
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1056653=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci Bot commented Feb 23, 2026

Pull request for series with
subject: blk-integrity: support arbitrary buffer alignment
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1056653

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Feb 23, 2026

Upstream branch: 6de23f8
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Feb 25, 2026

Upstream branch: 7dff99b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from b412689 to 9c4134d Compare February 25, 2026 11:16
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from c475e20 to 14f6b99 Compare February 27, 2026 16:24
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Feb 27, 2026

Upstream branch: a75cb86
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 9c4134d to 19e64d2 Compare February 27, 2026 16:26
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 14f6b99 to 856dc37 Compare February 27, 2026 22:07
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Feb 27, 2026

Upstream branch: 4d349ee
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 19e64d2 to 551fcd3 Compare February 27, 2026 22:09
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 856dc37 to 40967f0 Compare March 2, 2026 09:22
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 2, 2026

Upstream branch: 11439c4
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 551fcd3 to b689ffa Compare March 2, 2026 09:24
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 40967f0 to d4e9bad Compare March 2, 2026 23:54
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 2, 2026

Upstream branch: af4e9ef
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from b689ffa to 800339e Compare March 2, 2026 23:56
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from d4e9bad to ecd10e2 Compare March 4, 2026 07:44
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 4, 2026

Upstream branch: af4e9ef
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 800339e to 9202378 Compare March 4, 2026 07:45
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from d0e1bed to 6b51c57 Compare March 4, 2026 09:34
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 4, 2026

Upstream branch: 0031c06
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 9202378 to 0183668 Compare March 4, 2026 09:46
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 6b51c57 to 78036b2 Compare March 4, 2026 19:57
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 4, 2026

Upstream branch: ecc64d2
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 0183668 to 7c7eab7 Compare March 4, 2026 20:08
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 78036b2 to bbb3394 Compare March 5, 2026 12:20
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 5, 2026

Upstream branch: c107785
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 7c7eab7 to 6de080f Compare March 5, 2026 12:31
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from bbb3394 to 901a429 Compare March 5, 2026 21:37
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 5, 2026

Upstream branch: 5ee8dbf
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 6de080f to 00c1d08 Compare March 5, 2026 21:48
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 901a429 to 1f19ba6 Compare March 10, 2026 06:29
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 10, 2026

Upstream branch: 1f318b9
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 00c1d08 to b87ce81 Compare March 10, 2026 06:40
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 1f19ba6 to e79276a Compare March 11, 2026 08:02
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 11, 2026

Upstream branch: None
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from b87ce81 to 259c252 Compare March 11, 2026 08:14
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from e79276a to 0dd9afc Compare March 12, 2026 01:40
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 12, 2026

Upstream branch: 80234b5
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 259c252 to 03e22b2 Compare March 12, 2026 02:10
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 0dd9afc to 2e598ed Compare March 13, 2026 07:29
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" <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 13, 2026

Upstream branch: 0257f64
series: https://patchwork.kernel.org/project/linux-block/list/?series=1056653
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1056653=>linus-master branch from 03e22b2 to 6742114 Compare March 13, 2026 07:46
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Mar 13, 2026

Upstream branch: 0257f64
series: https://patchwork.kernel.org/project/linux-block/list/?series=1066411
version: 1

Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/project/linux-block/list/?series=1066411
error message:

Cmd('git') failed due to: exit code(128)
  cmdline: git am --3way
  stdout: 'Applying: blk-integrity: support arbitrary buffer alignment
Using index info to reconstruct a base tree...
M	block/blk-settings.c
M	block/t10-pi.c
M	drivers/nvme/host/core.c
M	include/linux/blk-integrity.h
Falling back to patching base and 3-way merge...
Auto-merging include/linux/blk-integrity.h
Auto-merging drivers/nvme/host/core.c
Auto-merging block/t10-pi.c
CONFLICT (content): Merge conflict in block/t10-pi.c
Auto-merging block/blk-settings.c
Patch failed at 0001 blk-integrity: support arbitrary buffer alignment'
  stderr: 'error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"'

conflict:

diff --cc block/t10-pi.c
index 0c4ed9702146,a19b4e102a83..000000000000
--- a/block/t10-pi.c
+++ b/block/t10-pi.c
@@@ -372,83 -471,80 +471,96 @@@ static void blk_reftag_remap_complete(s
  	}
  }
  
++<<<<<<< HEAD
 +void blk_integrity_generate(struct bio *bio)
++=======
+ static void blk_set_ext_map_ref(struct crc64_pi_tuple *pi, u64 virt,
+ 				u64 ref_tag)
++>>>>>>> blk-integrity: support arbitrary buffer alignment
  {
- 	struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
- 	struct bio_integrity_payload *bip = bio_integrity(bio);
- 	struct blk_integrity_iter iter;
- 	struct bvec_iter bviter;
- 	struct bio_vec bv;
- 
- 	iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
- 	iter.interval = 1 << bi->interval_exp;
- 	iter.seed = bio->bi_iter.bi_sector;
- 	iter.prot_buf = bvec_virt(bip->bip_vec);
- 	bio_for_each_segment(bv, bio, bviter) {
- 		void *kaddr = bvec_kmap_local(&bv);
+ 	u64 ref = get_unaligned_be48(&pi->ref_tag);
  
- 		iter.data_buf = kaddr;
- 		iter.data_size = bv.bv_len;
- 		switch (bi->csum_type) {
- 		case BLK_INTEGRITY_CSUM_CRC64:
- 			ext_pi_crc64_generate(&iter, bi);
- 			break;
- 		case BLK_INTEGRITY_CSUM_CRC:
- 		case BLK_INTEGRITY_CSUM_IP:
- 			t10_pi_generate(&iter, bi);
- 			break;
- 		default:
- 			break;
- 		}
- 		kunmap_local(kaddr);
+ 	if (ref == lower_48_bits(virt) && ref != ref_tag)
+ 		put_unaligned_be48(ref_tag, pi->ref_tag);
+ }
+ 
+ static void blk_set_t10_map_ref(struct t10_pi_tuple *pi, u32 virt, u32 ref_tag)
+ {
+ 	u32 ref = get_unaligned_be32(&pi->ref_tag);
+ 
+ 	if (ref == virt && ref != ref_tag)
+ 		put_unaligned_be32(ref_tag, &pi->ref_tag);
+ }
+ 
+ static void blk_reftag_remap_prepare(struct blk_integrity *bi,
+ 				     union pi_tuple *tuple,
+ 				     u64 virt, u64 ref)
+ {
+ 	switch (bi->csum_type) {
+ 	case BLK_INTEGRITY_CSUM_CRC64:
+ 		blk_set_ext_map_ref(&tuple->crc64_pi, virt, ref);
+ 		break;
+ 	case BLK_INTEGRITY_CSUM_CRC:
+ 	case BLK_INTEGRITY_CSUM_IP:
+ 		blk_set_t10_map_ref(&tuple->t10_pi, virt, ref);
+ 		break;
+ 	default:
+ 		WARN_ON_ONCE(1);
+ 		break;
  	}
  }
  
++<<<<<<< HEAD
 +void blk_integrity_verify_iter(struct bio *bio, struct bvec_iter *saved_iter)
++=======
+ static void __blk_reftag_remap(struct bio *bio, struct blk_integrity *bi,
+ 			       unsigned *intervals, u64 *ref, bool prep)
++>>>>>>> blk-integrity: support arbitrary buffer alignment
  {
- 	struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
  	struct bio_integrity_payload *bip = bio_integrity(bio);
- 	struct blk_integrity_iter iter;
- 	struct bvec_iter bviter;
- 	struct bio_vec bv;
+ 	struct bvec_iter iter = bip->bip_iter;
+ 	u64 virt = bip_get_seed(bip);
+ 	union pi_tuple *ptuple;
+ 	union pi_tuple tuple;
  
- 	/*
- 	 * At the moment verify is called bi_iter has been advanced during split
- 	 * and completion, so use the copy created during submission here.
- 	 */
- 	iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
- 	iter.interval = 1 << bi->interval_exp;
- 	iter.seed = saved_iter->bi_sector;
- 	iter.prot_buf = bvec_virt(bip->bip_vec);
- 	__bio_for_each_segment(bv, bio, bviter, *saved_iter) {
- 		void *kaddr = bvec_kmap_local(&bv);
- 		blk_status_t ret = BLK_STS_OK;
+ 	if (prep && bip->bip_flags & BIP_MAPPED_INTEGRITY) {
+ 		*ref += bio->bi_iter.bi_size >> bi->interval_exp;
+ 		return;
+ 	}
  
- 		iter.data_buf = kaddr;
- 		iter.data_size = bv.bv_len;
- 		switch (bi->csum_type) {
- 		case BLK_INTEGRITY_CSUM_CRC64:
- 			ret = ext_pi_crc64_verify(&iter, bi);
- 			break;
- 		case BLK_INTEGRITY_CSUM_CRC:
- 		case BLK_INTEGRITY_CSUM_IP:
- 			ret = t10_pi_verify(&iter, bi);
- 			break;
- 		default:
- 			break;
- 		}
- 		kunmap_local(kaddr);
+ 	while (iter.bi_size && *intervals) {
+ 		ptuple = blk_tuple_remap_begin(&tuple, bi, bip, &iter);
+ 
+ 		if (prep)
+ 			blk_reftag_remap_prepare(bi, ptuple, virt, *ref);
+ 		else
+ 			blk_reftag_remap_complete(bi, ptuple, virt, *ref);
  
++<<<<<<< HEAD
 +		if (ret) {
 +			bio->bi_status = ret;
 +			return;
 +		}
 +	}
++=======
+ 		blk_tuple_remap_end(&tuple, ptuple, bi, bip, &iter);
+ 		(*intervals)--;
+ 		(*ref)++;
+ 		virt++;
+ 	}
+ 
+ 	if (prep)
+ 		bip->bip_flags |= BIP_MAPPED_INTEGRITY;
++>>>>>>> blk-integrity: support arbitrary buffer alignment
  }
  
- void blk_integrity_prepare(struct request *rq)
+ static void blk_integrity_remap(struct request *rq, unsigned int nr_bytes,
+ 				bool prep)
  {
  	struct blk_integrity *bi = &rq->q->limits.integrity;
+ 	u64 ref = blk_rq_pos(rq) >> (bi->interval_exp - SECTOR_SHIFT);
+ 	unsigned intervals = nr_bytes >> bi->interval_exp;
+ 	struct bio *bio;
  
  	if (!(bi->flags & BLK_INTEGRITY_REF_TAG))
  		return;

@blktests-ci blktests-ci Bot closed this Mar 13, 2026
@blktests-ci blktests-ci Bot deleted the series/1056653=>linus-master branch March 15, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant