linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 0/1] t10-pi bio split fix
@ 2022-02-02 17:42 Ivanov, Dmitry (HPC)
  2022-02-04  3:44 ` Martin K. Petersen
  0 siblings, 1 reply; 9+ messages in thread
From: Ivanov, Dmitry (HPC) @ 2022-02-02 17:42 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Damien Le Moal, Jens Axboe, Bart Van Assche, Lyashkov, Alexey,
	Dmitry Fomichev, linux-block@vger.kernel.org,
	linux-scsi@vger.kernel.org

On 14/01/2022, 12:25 +0000, "Martin K. Petersen" <martin.petersen@xxxxxxxxxx> wrote:

> Can you please try the following patch?
> 
> Martin K. Petersen	Oracle Linux Engineering
> 
> diff --git a/block/bio-integrity.c b/block/bio-integrity.c
> index c0eb901315f9..fa5bc5b13c6a 100644
> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -387,7 +387,7 @@ void bio_integrity_advance(struct bio *bio, unsigned int bytes_done)
> 	struct blk_integrity *bi = blk_get_integrity(bio->bi_disk);
> 	unsigned bytes = bio_integrity_bytes(bi, bytes_done >> 9);
> 
> -	bip->bip_iter.bi_sector += bytes_done >> 9;
> +	bip->bip_iter.bi_sector += bio_integrity_intervals(bi, bytes_done >> 9);
> 	bvec_iter_advance(bip->bip_vec, &bip->bip_iter, bytes);
> }

I encountered the same issue as Alexey did when writing to DPS Type 2 formatted, 8 bytes metadata NVME device(s) from a stacked driver if bio was split in md layer.
Virtual ref_tags were improperly converted to ref_tags by the block integrity prepare_fn().
The Martin's patch has resolved this issue.

Martin, could you please advance with this patch?

My only concern is dm_crypt target which operates on bip_iter directly with the code copy-pasted from bio_integrity_advance:

static int dm_crypt_integrity_io_alloc(struct dm_crypt_io *io, struct bio *bio)
{
	struct bio_integrity_payload *bip;
	unsigned int tag_len;
	int ret;

	if (!bio_sectors(bio) || !io->cc->on_disk_tag_size)
		return 0;

	bip = bio_integrity_alloc(bio, GFP_NOIO, 1);
	if (IS_ERR(bip))
		return PTR_ERR(bip);

	tag_len = io->cc->on_disk_tag_size * (bio_sectors(bio) >> io->cc->sector_shift);

	bip->bip_iter.bi_size = tag_len;
	bip->bip_iter.bi_sector = io->cc->start + io->sector;
               ^^^

	ret = bio_integrity_add_page(bio, virt_to_page(io->integrity_metadata),
				     tag_len, offset_in_page(io->integrity_metadata));
...
}
Not sure if there is another place in drivers where bip iterator is advanced explicitly, i.e. without calling bio_integrity_advance/bio_advance.

--
Dmitry Ivanov
Hewlett Packard Enterprise - HPC AI Labs

^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <20211220134422.1045336-1-alexey.lyashkov@hpe.com>]

end of thread, other threads:[~2022-02-05  3:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-02 17:42 [PATCH 0/1] t10-pi bio split fix Ivanov, Dmitry (HPC)
2022-02-04  3:44 ` Martin K. Petersen
2022-02-04  7:43   ` Milan Broz
2022-02-04  7:58     ` Lyashkov, Alexey
2022-02-05  3:03     ` Ivanov, Dmitry (HPC)
     [not found] <20211220134422.1045336-1-alexey.lyashkov@hpe.com>
     [not found] ` <yq1wnjzi6oc.fsf@ca-mkp.ca.oracle.com>
     [not found]   ` <82F812AE-BEFA-4F57-A134-C1EED7F1928E@hpe.com>
2021-12-30  2:23     ` Damien Le Moal
2022-01-13 11:13       ` Lyashkov, Alexey
2022-01-13 19:59         ` Martin K. Petersen
2022-01-14 12:25           ` Lyashkov, Alexey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).