aboutsummaryrefslogtreecommitdiffstats
path: root/block/bio-integrity.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/bio-integrity.c')
-rw-r--r--block/bio-integrity.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index e84f7fb8694b..6a3aacf57b19 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -185,20 +185,20 @@ bool bio_integrity_enabled(struct bio *bio)
185EXPORT_SYMBOL(bio_integrity_enabled); 185EXPORT_SYMBOL(bio_integrity_enabled);
186 186
187/** 187/**
188 * bio_integrity_hw_sectors - Convert 512b sectors to hardware ditto 188 * bio_integrity_intervals - Return number of integrity intervals for a bio
189 * @bi: blk_integrity profile for device 189 * @bi: blk_integrity profile for device
190 * @sectors: Number of 512 sectors to convert 190 * @sectors: Size of the bio in 512-byte sectors
191 * 191 *
192 * Description: The block layer calculates everything in 512 byte 192 * Description: The block layer calculates everything in 512 byte
193 * sectors but integrity metadata is done in terms of the hardware 193 * sectors but integrity metadata is done in terms of the data integrity
194 * sector size of the storage device. Convert the block layer sectors 194 * interval size of the storage device. Convert the block layer sectors
195 * to physical sectors. 195 * to the appropriate number of integrity intervals.
196 */ 196 */
197static inline unsigned int bio_integrity_hw_sectors(struct blk_integrity *bi, 197static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
198 unsigned int sectors) 198 unsigned int sectors)
199{ 199{
200 /* At this point there are only 512b or 4096b DIF/EPP devices */ 200 /* At this point there are only 512b or 4096b DIF/EPP devices */
201 if (bi->sector_size == 4096) 201 if (bi->interval == 4096)
202 return sectors >>= 3; 202 return sectors >>= 3;
203 203
204 return sectors; 204 return sectors;
@@ -207,7 +207,7 @@ static inline unsigned int bio_integrity_hw_sectors(struct blk_integrity *bi,
207static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, 207static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
208 unsigned int sectors) 208 unsigned int sectors)
209{ 209{
210 return bio_integrity_hw_sectors(bi, sectors) * bi->tuple_size; 210 return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
211} 211}
212 212
213/** 213/**
@@ -221,25 +221,25 @@ static int bio_integrity_generate_verify(struct bio *bio, int operate)
221 struct blk_integrity_exchg bix; 221 struct blk_integrity_exchg bix;
222 struct bio_vec *bv; 222 struct bio_vec *bv;
223 struct bio_integrity_payload *bip = bio_integrity(bio); 223 struct bio_integrity_payload *bip = bio_integrity(bio);
224 sector_t sector; 224 sector_t seed;
225 unsigned int sectors, ret = 0, i; 225 unsigned int intervals, ret = 0, i;
226 void *prot_buf = page_address(bip->bip_vec->bv_page) + 226 void *prot_buf = page_address(bip->bip_vec->bv_page) +
227 bip->bip_vec->bv_offset; 227 bip->bip_vec->bv_offset;
228 228
229 if (operate) 229 if (operate)
230 sector = bio->bi_iter.bi_sector; 230 seed = bio->bi_iter.bi_sector;
231 else 231 else
232 sector = bip->bip_iter.bi_sector; 232 seed = bip->bip_iter.bi_sector;
233 233
234 bix.disk_name = bio->bi_bdev->bd_disk->disk_name; 234 bix.disk_name = bio->bi_bdev->bd_disk->disk_name;
235 bix.sector_size = bi->sector_size; 235 bix.interval = bi->interval;
236 236
237 bio_for_each_segment_all(bv, bio, i) { 237 bio_for_each_segment_all(bv, bio, i) {
238 void *kaddr = kmap_atomic(bv->bv_page); 238 void *kaddr = kmap_atomic(bv->bv_page);
239 bix.data_buf = kaddr + bv->bv_offset; 239 bix.data_buf = kaddr + bv->bv_offset;
240 bix.data_size = bv->bv_len; 240 bix.data_size = bv->bv_len;
241 bix.prot_buf = prot_buf; 241 bix.prot_buf = prot_buf;
242 bix.sector = sector; 242 bix.seed = seed;
243 243
244 if (operate) 244 if (operate)
245 bi->generate_fn(&bix); 245 bi->generate_fn(&bix);
@@ -251,9 +251,9 @@ static int bio_integrity_generate_verify(struct bio *bio, int operate)
251 } 251 }
252 } 252 }
253 253
254 sectors = bv->bv_len / bi->sector_size; 254 intervals = bv->bv_len / bi->interval;
255 sector += sectors; 255 seed += intervals;
256 prot_buf += sectors * bi->tuple_size; 256 prot_buf += intervals * bi->tuple_size;
257 257
258 kunmap_atomic(kaddr); 258 kunmap_atomic(kaddr);
259 } 259 }
@@ -294,17 +294,17 @@ int bio_integrity_prep(struct bio *bio)
294 unsigned long start, end; 294 unsigned long start, end;
295 unsigned int len, nr_pages; 295 unsigned int len, nr_pages;
296 unsigned int bytes, offset, i; 296 unsigned int bytes, offset, i;
297 unsigned int sectors; 297 unsigned int intervals;
298 298
299 bi = bdev_get_integrity(bio->bi_bdev); 299 bi = bdev_get_integrity(bio->bi_bdev);
300 q = bdev_get_queue(bio->bi_bdev); 300 q = bdev_get_queue(bio->bi_bdev);
301 BUG_ON(bi == NULL); 301 BUG_ON(bi == NULL);
302 BUG_ON(bio_integrity(bio)); 302 BUG_ON(bio_integrity(bio));
303 303
304 sectors = bio_integrity_hw_sectors(bi, bio_sectors(bio)); 304 intervals = bio_integrity_intervals(bi, bio_sectors(bio));
305 305
306 /* Allocate kernel buffer for protection data */ 306 /* Allocate kernel buffer for protection data */
307 len = sectors * bi->tuple_size; 307 len = intervals * bi->tuple_size;
308 buf = kmalloc(len, GFP_NOIO | q->bounce_gfp); 308 buf = kmalloc(len, GFP_NOIO | q->bounce_gfp);
309 if (unlikely(buf == NULL)) { 309 if (unlikely(buf == NULL)) {
310 printk(KERN_ERR "could not allocate integrity buffer\n"); 310 printk(KERN_ERR "could not allocate integrity buffer\n");