aboutsummaryrefslogtreecommitdiffstats
path: root/block/bio-integrity.c
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2014-09-26 19:19:57 -0400
committerJens Axboe <axboe@fb.com>2014-09-27 11:14:50 -0400
commit8492b68bc4025e7bce1d57761bd7c047efda2f81 (patch)
treeef444c4e2a55354e1d7c515e4e5e800f0734168d /block/bio-integrity.c
parent180b2f95dd331010a9930a65c8a18d6d81b94dc1 (diff)
block: Remove integrity tagging functions
None of the filesystems appear interested in using the integrity tagging feature. Potentially because very few storage devices actually permit using the application tag space. Remove the tagging functions. 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/bio-integrity.c')
-rw-r--r--block/bio-integrity.c94
1 files changed, 1 insertions, 93 deletions
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index bd3125c3c124..367bb24bb9f1 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -210,90 +210,6 @@ static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
210} 210}
211 211
212/** 212/**
213 * bio_integrity_tag_size - Retrieve integrity tag space
214 * @bio: bio to inspect
215 *
216 * Description: Returns the maximum number of tag bytes that can be
217 * attached to this bio. Filesystems can use this to determine how
218 * much metadata to attach to an I/O.
219 */
220unsigned int bio_integrity_tag_size(struct bio *bio)
221{
222 struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
223
224 BUG_ON(bio->bi_iter.bi_size == 0);
225
226 return bi->tag_size * (bio->bi_iter.bi_size / bi->sector_size);
227}
228EXPORT_SYMBOL(bio_integrity_tag_size);
229
230static int bio_integrity_tag(struct bio *bio, void *tag_buf, unsigned int len,
231 int set)
232{
233 struct bio_integrity_payload *bip = bio_integrity(bio);
234 struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
235 unsigned int nr_sectors;
236
237 BUG_ON(bip->bip_buf == NULL);
238
239 if (bi->tag_size == 0)
240 return -1;
241
242 nr_sectors = bio_integrity_hw_sectors(bi,
243 DIV_ROUND_UP(len, bi->tag_size));
244
245 if (nr_sectors * bi->tuple_size > bip->bip_iter.bi_size) {
246 printk(KERN_ERR "%s: tag too big for bio: %u > %u\n", __func__,
247 nr_sectors * bi->tuple_size, bip->bip_iter.bi_size);
248 return -1;
249 }
250
251 if (set)
252 bi->set_tag_fn(bip->bip_buf, tag_buf, nr_sectors);
253 else
254 bi->get_tag_fn(bip->bip_buf, tag_buf, nr_sectors);
255
256 return 0;
257}
258
259/**
260 * bio_integrity_set_tag - Attach a tag buffer to a bio
261 * @bio: bio to attach buffer to
262 * @tag_buf: Pointer to a buffer containing tag data
263 * @len: Length of the included buffer
264 *
265 * Description: Use this function to tag a bio by leveraging the extra
266 * space provided by devices formatted with integrity protection. The
267 * size of the integrity buffer must be <= to the size reported by
268 * bio_integrity_tag_size().
269 */
270int bio_integrity_set_tag(struct bio *bio, void *tag_buf, unsigned int len)
271{
272 BUG_ON(bio_data_dir(bio) != WRITE);
273
274 return bio_integrity_tag(bio, tag_buf, len, 1);
275}
276EXPORT_SYMBOL(bio_integrity_set_tag);
277
278/**
279 * bio_integrity_get_tag - Retrieve a tag buffer from a bio
280 * @bio: bio to retrieve buffer from
281 * @tag_buf: Pointer to a buffer for the tag data
282 * @len: Length of the target buffer
283 *
284 * Description: Use this function to retrieve the tag buffer from a
285 * completed I/O. The size of the integrity buffer must be <= to the
286 * size reported by bio_integrity_tag_size().
287 */
288int bio_integrity_get_tag(struct bio *bio, void *tag_buf, unsigned int len)
289{
290 BUG_ON(bio_data_dir(bio) != READ);
291
292 return bio_integrity_tag(bio, tag_buf, len, 0);
293}
294EXPORT_SYMBOL(bio_integrity_get_tag);
295
296/**
297 * bio_integrity_generate_verify - Generate/verify integrity metadata for a bio 213 * bio_integrity_generate_verify - Generate/verify integrity metadata for a bio
298 * @bio: bio to generate/verify integrity metadata for 214 * @bio: bio to generate/verify integrity metadata for
299 * @operate: operate number, 1 for generate, 0 for verify 215 * @operate: operate number, 1 for generate, 0 for verify
@@ -355,14 +271,6 @@ static void bio_integrity_generate(struct bio *bio)
355 bio_integrity_generate_verify(bio, 1); 271 bio_integrity_generate_verify(bio, 1);
356} 272}
357 273
358static inline unsigned short blk_integrity_tuple_size(struct blk_integrity *bi)
359{
360 if (bi)
361 return bi->tuple_size;
362
363 return 0;
364}
365
366/** 274/**
367 * bio_integrity_prep - Prepare bio for integrity I/O 275 * bio_integrity_prep - Prepare bio for integrity I/O
368 * @bio: bio to prepare 276 * @bio: bio to prepare
@@ -393,7 +301,7 @@ int bio_integrity_prep(struct bio *bio)
393 sectors = bio_integrity_hw_sectors(bi, bio_sectors(bio)); 301 sectors = bio_integrity_hw_sectors(bi, bio_sectors(bio));
394 302
395 /* Allocate kernel buffer for protection data */ 303 /* Allocate kernel buffer for protection data */
396 len = sectors * blk_integrity_tuple_size(bi); 304 len = sectors * bi->tuple_size;
397 buf = kmalloc(len, GFP_NOIO | q->bounce_gfp); 305 buf = kmalloc(len, GFP_NOIO | q->bounce_gfp);
398 if (unlikely(buf == NULL)) { 306 if (unlikely(buf == NULL)) {
399 printk(KERN_ERR "could not allocate integrity buffer\n"); 307 printk(KERN_ERR "could not allocate integrity buffer\n");