Skip to content

Commit c340b99

Browse files
keithbuschaxboe
authored andcommitted
block: support pi with extended metadata
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>
1 parent d57c1cf commit c340b99

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

block/bio-integrity.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static blk_status_t bio_integrity_process(struct bio *bio,
165165

166166
iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
167167
iter.interval = 1 << bi->interval_exp;
168+
iter.tuple_size = bi->tuple_size;
168169
iter.seed = proc_iter->bi_sector;
169170
iter.prot_buf = bvec_virt(bip->bip_vec);
170171

block/t10-pi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
4444
pi->ref_tag = 0;
4545

4646
iter->data_buf += iter->interval;
47-
iter->prot_buf += sizeof(struct t10_pi_tuple);
47+
iter->prot_buf += iter->tuple_size;
4848
iter->seed++;
4949
}
5050

@@ -93,7 +93,7 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
9393

9494
next:
9595
iter->data_buf += iter->interval;
96-
iter->prot_buf += sizeof(struct t10_pi_tuple);
96+
iter->prot_buf += iter->tuple_size;
9797
iter->seed++;
9898
}
9999

include/linux/blk-integrity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct blk_integrity_iter {
1919
sector_t seed;
2020
unsigned int data_size;
2121
unsigned short interval;
22+
unsigned char tuple_size;
2223
const char *disk_name;
2324
};
2425

0 commit comments

Comments
 (0)