block: support pi with extended metadata
authorKeith Busch <kbusch@kernel.org>
Thu, 3 Mar 2022 20:13:05 +0000 (12:13 -0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 7 Mar 2022 19:48:35 +0000 (12:48 -0700)
The nvme spec allows protection information formats with metadata
extending beyond the pi field. Use the actual size of the metadata field
for incrementing the buffer.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20220303201312.3255347-2-kbusch@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity.c
block/t10-pi.c
include/linux/blk-integrity.h

index 6996e7bd66e9e10fa8f7aaae2cbb6ab115f905d8..32929c89ba8a621c07768c0183ee21383ab5dab1 100644 (file)
@@ -165,6 +165,7 @@ static blk_status_t bio_integrity_process(struct bio *bio,
 
        iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
        iter.interval = 1 << bi->interval_exp;
+       iter.tuple_size = bi->tuple_size;
        iter.seed = proc_iter->bi_sector;
        iter.prot_buf = bvec_virt(bip->bip_vec);
 
index 25a52a2a09a885023b66a54777c262fc1f30b355..758a7651885462ba700fb2ad9b5cb3d1a87a2f94 100644 (file)
@@ -44,7 +44,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
                        pi->ref_tag = 0;
 
                iter->data_buf += iter->interval;
-               iter->prot_buf += sizeof(struct t10_pi_tuple);
+               iter->prot_buf += iter->tuple_size;
                iter->seed++;
        }
 
@@ -93,7 +93,7 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
 
 next:
                iter->data_buf += iter->interval;
-               iter->prot_buf += sizeof(struct t10_pi_tuple);
+               iter->prot_buf += iter->tuple_size;
                iter->seed++;
        }
 
index 8a038ea0717e446b5992256dba71f6087301d905..378b2459efe2da03565997d0980ed10656516c17 100644 (file)
@@ -19,6 +19,7 @@ struct blk_integrity_iter {
        sector_t                seed;
        unsigned int            data_size;
        unsigned short          interval;
+       unsigned char           tuple_size;
        const char              *disk_name;
 };