[PATCH v4] bio-integrity-fs: pass data iter to bio_integrity_verify()

Caleb Sander Mateos posted 1 patch 4 weeks, 1 day ago
block/bio-integrity-fs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH v4] bio-integrity-fs: pass data iter to bio_integrity_verify()
Posted by Caleb Sander Mateos 4 weeks, 1 day ago
bio_integrity_verify() expects the passed struct bvec_iter to be an
iterator over bio data, not integrity. So construct a separate data
bvec_iter without the bio_integrity_bytes() conversion and pass it to
bio_integrity_verify() instead of bip_iter.

Fixes: 0bde8a12b554 ("block: add fs_bio_integrity helpers")
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
v4: split from series changing ref tag seed units
v3: https://lore.kernel.org/linux-block/20260417015732.2692434-3-csander@purestorage.com/

 block/bio-integrity-fs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/bio-integrity-fs.c b/block/bio-integrity-fs.c
index acb1e5f270d2..0daa42d9ead7 100644
--- a/block/bio-integrity-fs.c
+++ b/block/bio-integrity-fs.c
@@ -53,21 +53,25 @@ EXPORT_SYMBOL_GPL(fs_bio_integrity_generate);
 
 int fs_bio_integrity_verify(struct bio *bio, sector_t sector, unsigned int size)
 {
 	struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
 	struct bio_integrity_payload *bip = bio_integrity(bio);
+	struct bvec_iter data_iter = {
+		.bi_sector	= sector,
+		.bi_size	= size,
+	};
 
 	/*
 	 * Reinitialize bip->bip_iter.
 	 *
 	 * This is for use in the submitter after the driver is done with the
 	 * bio.  Requires the submitter to remember the sector and the size.
 	 */
 	memset(&bip->bip_iter, 0, sizeof(bip->bip_iter));
 	bip->bip_iter.bi_sector = sector;
 	bip->bip_iter.bi_size = bio_integrity_bytes(bi, size >> SECTOR_SHIFT);
-	return blk_status_to_errno(bio_integrity_verify(bio, &bip->bip_iter));
+	return blk_status_to_errno(bio_integrity_verify(bio, &data_iter));
 }
 
 static int __init fs_bio_integrity_init(void)
 {
 	fs_bio_integrity_cache = kmem_cache_create("fs_bio_integrity",
-- 
2.54.0
Re: [PATCH v4] bio-integrity-fs: pass data iter to bio_integrity_verify()
Posted by Jens Axboe 3 weeks, 2 days ago
On Wed, 13 May 2026 12:29:21 -0600, Caleb Sander Mateos wrote:
> bio_integrity_verify() expects the passed struct bvec_iter to be an
> iterator over bio data, not integrity. So construct a separate data
> bvec_iter without the bio_integrity_bytes() conversion and pass it to
> bio_integrity_verify() instead of bip_iter.

Applied, thanks!

[1/1] bio-integrity-fs: pass data iter to bio_integrity_verify()
      commit: 431e40042d3599559e588b8946bb28bd440b4f65

Best regards,
-- 
Jens Axboe
Re: [PATCH v4] bio-integrity-fs: pass data iter to bio_integrity_verify()
Posted by Caleb Sander Mateos 3 weeks, 2 days ago
Hi Jens,
Gentle ping on this fix for 7.1.

Thanks,
Caleb

On Wed, May 13, 2026 at 11:29 AM Caleb Sander Mateos
<csander@purestorage.com> wrote:
>
> bio_integrity_verify() expects the passed struct bvec_iter to be an
> iterator over bio data, not integrity. So construct a separate data
> bvec_iter without the bio_integrity_bytes() conversion and pass it to
> bio_integrity_verify() instead of bip_iter.
>
> Fixes: 0bde8a12b554 ("block: add fs_bio_integrity helpers")
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
> v4: split from series changing ref tag seed units
> v3: https://lore.kernel.org/linux-block/20260417015732.2692434-3-csander@purestorage.com/
>
>  block/bio-integrity-fs.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/block/bio-integrity-fs.c b/block/bio-integrity-fs.c
> index acb1e5f270d2..0daa42d9ead7 100644
> --- a/block/bio-integrity-fs.c
> +++ b/block/bio-integrity-fs.c
> @@ -53,21 +53,25 @@ EXPORT_SYMBOL_GPL(fs_bio_integrity_generate);
>
>  int fs_bio_integrity_verify(struct bio *bio, sector_t sector, unsigned int size)
>  {
>         struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
>         struct bio_integrity_payload *bip = bio_integrity(bio);
> +       struct bvec_iter data_iter = {
> +               .bi_sector      = sector,
> +               .bi_size        = size,
> +       };
>
>         /*
>          * Reinitialize bip->bip_iter.
>          *
>          * This is for use in the submitter after the driver is done with the
>          * bio.  Requires the submitter to remember the sector and the size.
>          */
>         memset(&bip->bip_iter, 0, sizeof(bip->bip_iter));
>         bip->bip_iter.bi_sector = sector;
>         bip->bip_iter.bi_size = bio_integrity_bytes(bi, size >> SECTOR_SHIFT);
> -       return blk_status_to_errno(bio_integrity_verify(bio, &bip->bip_iter));
> +       return blk_status_to_errno(bio_integrity_verify(bio, &data_iter));
>  }
>
>  static int __init fs_bio_integrity_init(void)
>  {
>         fs_bio_integrity_cache = kmem_cache_create("fs_bio_integrity",
> --
> 2.54.0
>