Skip to content

Commit 8492b68

Browse files
martinkpetersenaxboe
authored andcommitted
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>
1 parent 180b2f9 commit 8492b68

6 files changed

Lines changed: 1 addition & 201 deletions

File tree

‎Documentation/block/data-integrity.txt‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -206,36 +206,6 @@ will require extra work due to the application tag.
206206
bio_integrity_enabled() returned 1.
207207

208208

209-
int bio_integrity_tag_size(bio);
210-
211-
If the filesystem wants to use the application tag space it will
212-
first have to find out how much storage space is available.
213-
Because tag space is generally limited (usually 2 bytes per
214-
sector regardless of sector size), the integrity framework
215-
supports interleaving the information between the sectors in an
216-
I/O.
217-
218-
Filesystems can call bio_integrity_tag_size(bio) to find out how
219-
many bytes of storage are available for that particular bio.
220-
221-
Another option is bdev_get_tag_size(block_device) which will
222-
return the number of available bytes per hardware sector.
223-
224-
225-
int bio_integrity_set_tag(bio, void *tag_buf, len);
226-
227-
After a successful return from bio_integrity_prep(),
228-
bio_integrity_set_tag() can be used to attach an opaque tag
229-
buffer to a bio. Obviously this only makes sense if the I/O is
230-
a WRITE.
231-
232-
233-
int bio_integrity_get_tag(bio, void *tag_buf, len);
234-
235-
Similarly, at READ I/O completion time the filesystem can
236-
retrieve the tag buffer using bio_integrity_get_tag().
237-
238-
239209
5.3 PASSING EXISTING INTEGRITY METADATA
240210

241211
Filesystems that either generate their own integrity metadata or
@@ -288,8 +258,6 @@ will require extra work due to the application tag.
288258
.name = "STANDARDSBODY-TYPE-VARIANT-CSUM",
289259
.generate_fn = my_generate_fn,
290260
.verify_fn = my_verify_fn,
291-
.get_tag_fn = my_get_tag_fn,
292-
.set_tag_fn = my_set_tag_fn,
293261
.tuple_size = sizeof(struct my_tuple_size),
294262
.tag_size = <tag bytes per hw sector>,
295263
};
@@ -311,7 +279,5 @@ will require extra work due to the application tag.
311279
are available per hardware sector. For DIF this is either 2 or
312280
0 depending on the value of the Control Mode Page ATO bit.
313281

314-
See 6.2 for a description of get_tag_fn and set_tag_fn.
315-
316282
----------------------------------------------------------------------
317283
2007-12-24 Martin K. Petersen <martin.petersen@oracle.com>

‎block/bio-integrity.c‎

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -209,90 +209,6 @@ static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
209209
return bio_integrity_hw_sectors(bi, sectors) * bi->tuple_size;
210210
}
211211

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-
*/
220-
unsigned 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-
}
228-
EXPORT_SYMBOL(bio_integrity_tag_size);
229-
230-
static 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-
*/
270-
int 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-
}
276-
EXPORT_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-
*/
288-
int 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-
}
294-
EXPORT_SYMBOL(bio_integrity_get_tag);
295-
296212
/**
297213
* bio_integrity_generate_verify - Generate/verify integrity metadata for a bio
298214
* @bio: bio to generate/verify integrity metadata for
@@ -355,14 +271,6 @@ static void bio_integrity_generate(struct bio *bio)
355271
bio_integrity_generate_verify(bio, 1);
356272
}
357273

358-
static 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-
366274
/**
367275
* bio_integrity_prep - Prepare bio for integrity I/O
368276
* @bio: bio to prepare
@@ -393,7 +301,7 @@ int bio_integrity_prep(struct bio *bio)
393301
sectors = bio_integrity_hw_sectors(bi, bio_sectors(bio));
394302

395303
/* Allocate kernel buffer for protection data */
396-
len = sectors * blk_integrity_tuple_size(bi);
304+
len = sectors * bi->tuple_size;
397305
buf = kmalloc(len, GFP_NOIO | q->bounce_gfp);
398306
if (unlikely(buf == NULL)) {
399307
printk(KERN_ERR "could not allocate integrity buffer\n");

‎block/blk-integrity.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,6 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
418418
bi->generate_fn = template->generate_fn;
419419
bi->verify_fn = template->verify_fn;
420420
bi->tuple_size = template->tuple_size;
421-
bi->set_tag_fn = template->set_tag_fn;
422-
bi->get_tag_fn = template->get_tag_fn;
423421
bi->tag_size = template->tag_size;
424422
} else
425423
bi->name = bi_unsupported_name;

‎drivers/scsi/sd_dif.c‎

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -128,39 +128,10 @@ static int sd_dif_type1_verify_ip(struct blk_integrity_exchg *bix)
128128
return sd_dif_type1_verify(bix, sd_dif_ip_fn);
129129
}
130130

131-
/*
132-
* Functions for interleaving and deinterleaving application tags
133-
*/
134-
static void sd_dif_type1_set_tag(void *prot, void *tag_buf, unsigned int sectors)
135-
{
136-
struct sd_dif_tuple *sdt = prot;
137-
u8 *tag = tag_buf;
138-
unsigned int i, j;
139-
140-
for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
141-
sdt->app_tag = tag[j] << 8 | tag[j+1];
142-
BUG_ON(sdt->app_tag == 0xffff);
143-
}
144-
}
145-
146-
static void sd_dif_type1_get_tag(void *prot, void *tag_buf, unsigned int sectors)
147-
{
148-
struct sd_dif_tuple *sdt = prot;
149-
u8 *tag = tag_buf;
150-
unsigned int i, j;
151-
152-
for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
153-
tag[j] = (sdt->app_tag & 0xff00) >> 8;
154-
tag[j+1] = sdt->app_tag & 0xff;
155-
}
156-
}
157-
158131
static struct blk_integrity dif_type1_integrity_crc = {
159132
.name = "T10-DIF-TYPE1-CRC",
160133
.generate_fn = sd_dif_type1_generate_crc,
161134
.verify_fn = sd_dif_type1_verify_crc,
162-
.get_tag_fn = sd_dif_type1_get_tag,
163-
.set_tag_fn = sd_dif_type1_set_tag,
164135
.tuple_size = sizeof(struct sd_dif_tuple),
165136
.tag_size = 0,
166137
};
@@ -169,8 +140,6 @@ static struct blk_integrity dif_type1_integrity_ip = {
169140
.name = "T10-DIF-TYPE1-IP",
170141
.generate_fn = sd_dif_type1_generate_ip,
171142
.verify_fn = sd_dif_type1_verify_ip,
172-
.get_tag_fn = sd_dif_type1_get_tag,
173-
.set_tag_fn = sd_dif_type1_set_tag,
174143
.tuple_size = sizeof(struct sd_dif_tuple),
175144
.tag_size = 0,
176145
};
@@ -245,42 +214,10 @@ static int sd_dif_type3_verify_ip(struct blk_integrity_exchg *bix)
245214
return sd_dif_type3_verify(bix, sd_dif_ip_fn);
246215
}
247216

248-
static void sd_dif_type3_set_tag(void *prot, void *tag_buf, unsigned int sectors)
249-
{
250-
struct sd_dif_tuple *sdt = prot;
251-
u8 *tag = tag_buf;
252-
unsigned int i, j;
253-
254-
for (i = 0, j = 0 ; i < sectors ; i++, j += 6, sdt++) {
255-
sdt->app_tag = tag[j] << 8 | tag[j+1];
256-
sdt->ref_tag = tag[j+2] << 24 | tag[j+3] << 16 |
257-
tag[j+4] << 8 | tag[j+5];
258-
}
259-
}
260-
261-
static void sd_dif_type3_get_tag(void *prot, void *tag_buf, unsigned int sectors)
262-
{
263-
struct sd_dif_tuple *sdt = prot;
264-
u8 *tag = tag_buf;
265-
unsigned int i, j;
266-
267-
for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
268-
tag[j] = (sdt->app_tag & 0xff00) >> 8;
269-
tag[j+1] = sdt->app_tag & 0xff;
270-
tag[j+2] = (sdt->ref_tag & 0xff000000) >> 24;
271-
tag[j+3] = (sdt->ref_tag & 0xff0000) >> 16;
272-
tag[j+4] = (sdt->ref_tag & 0xff00) >> 8;
273-
tag[j+5] = sdt->ref_tag & 0xff;
274-
BUG_ON(sdt->app_tag == 0xffff || sdt->ref_tag == 0xffffffff);
275-
}
276-
}
277-
278217
static struct blk_integrity dif_type3_integrity_crc = {
279218
.name = "T10-DIF-TYPE3-CRC",
280219
.generate_fn = sd_dif_type3_generate_crc,
281220
.verify_fn = sd_dif_type3_verify_crc,
282-
.get_tag_fn = sd_dif_type3_get_tag,
283-
.set_tag_fn = sd_dif_type3_set_tag,
284221
.tuple_size = sizeof(struct sd_dif_tuple),
285222
.tag_size = 0,
286223
};
@@ -289,8 +226,6 @@ static struct blk_integrity dif_type3_integrity_ip = {
289226
.name = "T10-DIF-TYPE3-IP",
290227
.generate_fn = sd_dif_type3_generate_ip,
291228
.verify_fn = sd_dif_type3_verify_ip,
292-
.get_tag_fn = sd_dif_type3_get_tag,
293-
.set_tag_fn = sd_dif_type3_set_tag,
294229
.tuple_size = sizeof(struct sd_dif_tuple),
295230
.tag_size = 0,
296231
};

‎include/linux/bio.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ extern struct bio *bio_clone_fast(struct bio *, gfp_t, struct bio_set *);
362362
extern struct bio *bio_clone_bioset(struct bio *, gfp_t, struct bio_set *bs);
363363

364364
extern struct bio_set *fs_bio_set;
365-
unsigned int bio_integrity_tag_size(struct bio *bio);
366365

367366
static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
368367
{
@@ -674,8 +673,6 @@ extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, un
674673
extern void bio_integrity_free(struct bio *);
675674
extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
676675
extern bool bio_integrity_enabled(struct bio *bio);
677-
extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
678-
extern int bio_integrity_get_tag(struct bio *, void *, unsigned int);
679676
extern int bio_integrity_prep(struct bio *);
680677
extern void bio_integrity_endio(struct bio *, int);
681678
extern void bio_integrity_advance(struct bio *, unsigned int);

‎include/linux/blkdev.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,14 +1472,10 @@ struct blk_integrity_exchg {
14721472

14731473
typedef void (integrity_gen_fn) (struct blk_integrity_exchg *);
14741474
typedef int (integrity_vrfy_fn) (struct blk_integrity_exchg *);
1475-
typedef void (integrity_set_tag_fn) (void *, void *, unsigned int);
1476-
typedef void (integrity_get_tag_fn) (void *, void *, unsigned int);
14771475

14781476
struct blk_integrity {
14791477
integrity_gen_fn *generate_fn;
14801478
integrity_vrfy_fn *verify_fn;
1481-
integrity_set_tag_fn *set_tag_fn;
1482-
integrity_get_tag_fn *get_tag_fn;
14831479

14841480
unsigned short flags;
14851481
unsigned short tuple_size;

0 commit comments

Comments
 (0)