The seed value passed to the blk integrity metadata generation function
was wrong depending on the device block size (interval) and how many
blocks comprised the bvec. This patch converts the seed to 'interval'
units and increments it correctly for each iteration. Tested against a
4k+8 (w/ type1 PI) sector size.
Signed-off-by: Sam Bradshaw <[email protected]>
Signed-off-by: Selvan Mani <[email protected]>
---
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 5cbd5d9..7114040 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -219,20 +219,22 @@ static int bio_integrity_process(struct bio *bio,
struct bvec_iter bviter;
struct bio_vec bv;
struct bio_integrity_payload *bip = bio_integrity(bio);
- unsigned int ret = 0;
+ unsigned int len = 0, ret = 0;
void *prot_buf = page_address(bip->bip_vec->bv_page) +
bip->bip_vec->bv_offset;
+ sector_t seed, start = bio_integrity_intervals(bi, bip_get_seed(bip));
iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
iter.interval = bi->interval;
- iter.seed = bip_get_seed(bip);
- iter.prot_buf = prot_buf;
+ seed = start;
bio_for_each_segment(bv, bio, bviter) {
void *kaddr = kmap_atomic(bv.bv_page);
iter.data_buf = kaddr + bv.bv_offset;
iter.data_size = bv.bv_len;
+ iter.seed = seed;
+ iter.prot_buf = prot_buf;
ret = proc_fn(&iter);
if (ret) {
@@ -241,6 +243,9 @@ static int bio_integrity_process(struct bio *bio,
}
kunmap_atomic(kaddr);
+ len += bv.bv_len;
+ seed = start + (len / bi->interval);
+ prot_buf += bi->tuple_size;
}
return ret;
}