aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2014-09-26 19:19:59 -0400
committerJens Axboe <axboe@fb.com>2014-09-27 11:14:50 -0400
commit3be91c4a3d090bd700bd6ee5bf457c1bbf189a4f (patch)
tree235e86f4934f132dec54a4ec376886774a59fb1a /block
parent5f9378fa9ca214977b5bfc12197c67eea450fc40 (diff)
block: Deprecate the use of the term sector in the context of block integrity
The protection interval is not necessarily tied to the logical block size of a block device. Stop using the terms "sector" and "sectors". Going forward we will use the term "seed" to describe the initial reference tag value for a given I/O. "Interval" will be used to describe the portion of the data buffer that a given piece of protection information is associated with. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r--block/bio-integrity.c42
-rw-r--r--block/blk-integrity.c10
2 files changed, 26 insertions, 26 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");
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 7ac17160ab69..3a83a7d08177 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -154,10 +154,10 @@ int blk_integrity_compare(struct gendisk *gd1, struct gendisk *gd2)
154 if (!b1 || !b2) 154 if (!b1 || !b2)
155 return -1; 155 return -1;
156 156
157 if (b1->sector_size != b2->sector_size) { 157 if (b1->interval != b2->interval) {
158 printk(KERN_ERR "%s: %s/%s sector sz %u != %u\n", __func__, 158 pr_err("%s: %s/%s protection interval %u != %u\n",
159 gd1->disk_name, gd2->disk_name, 159 __func__, gd1->disk_name, gd2->disk_name,
160 b1->sector_size, b2->sector_size); 160 b1->interval, b2->interval);
161 return -1; 161 return -1;
162 } 162 }
163 163
@@ -407,7 +407,7 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
407 kobject_uevent(&bi->kobj, KOBJ_ADD); 407 kobject_uevent(&bi->kobj, KOBJ_ADD);
408 408
409 bi->flags |= INTEGRITY_FLAG_READ | INTEGRITY_FLAG_WRITE; 409 bi->flags |= INTEGRITY_FLAG_READ | INTEGRITY_FLAG_WRITE;
410 bi->sector_size = queue_logical_block_size(disk->queue); 410 bi->interval = queue_logical_block_size(disk->queue);
411 disk->integrity = bi; 411 disk->integrity = bi;
412 } else 412 } else
413 bi = disk->integrity; 413 bi = disk->integrity;