Commit fbd08e76 authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Jens Axboe

bio-integrity: fix interface for bio_integrity_trim

bio_integrity_trim inherent it's interface from bio_trim and accept
offset and size, but this API is error prone because data offset
must always be insync with bio's data offset. That is why we have
integrity update hook in bio_advance()

So only meaningful values are: offset == 0, sectors == bio_sectors(bio)
Let's just remove them completely.
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 309a62fa
...@@ -433,22 +433,15 @@ EXPORT_SYMBOL(bio_integrity_advance); ...@@ -433,22 +433,15 @@ EXPORT_SYMBOL(bio_integrity_advance);
/** /**
* bio_integrity_trim - Trim integrity vector * bio_integrity_trim - Trim integrity vector
* @bio: bio whose integrity vector to update * @bio: bio whose integrity vector to update
* @offset: offset to first data sector
* @sectors: number of data sectors
* *
* Description: Used to trim the integrity vector in a cloned bio. * Description: Used to trim the integrity vector in a cloned bio.
* The ivec will be advanced corresponding to 'offset' data sectors
* and the length will be truncated corresponding to 'len' data
* sectors.
*/ */
void bio_integrity_trim(struct bio *bio, unsigned int offset, void bio_integrity_trim(struct bio *bio)
unsigned int sectors)
{ {
struct bio_integrity_payload *bip = bio_integrity(bio); struct bio_integrity_payload *bip = bio_integrity(bio);
struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
bio_integrity_advance(bio, offset << 9); bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio));
bip->bip_iter.bi_size = bio_integrity_bytes(bi, sectors);
} }
EXPORT_SYMBOL(bio_integrity_trim); EXPORT_SYMBOL(bio_integrity_trim);
......
...@@ -1868,7 +1868,7 @@ struct bio *bio_split(struct bio *bio, int sectors, ...@@ -1868,7 +1868,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
split->bi_iter.bi_size = sectors << 9; split->bi_iter.bi_size = sectors << 9;
if (bio_integrity(split)) if (bio_integrity(split))
bio_integrity_trim(split, 0, sectors); bio_integrity_trim(split);
bio_advance(bio, split->bi_iter.bi_size); bio_advance(bio, split->bi_iter.bi_size);
...@@ -1902,7 +1902,7 @@ void bio_trim(struct bio *bio, int offset, int size) ...@@ -1902,7 +1902,7 @@ void bio_trim(struct bio *bio, int offset, int size)
bio->bi_iter.bi_size = size; bio->bi_iter.bi_size = size;
if (bio_integrity(bio)) if (bio_integrity(bio))
bio_integrity_trim(bio, 0, size); bio_integrity_trim(bio);
} }
EXPORT_SYMBOL_GPL(bio_trim); EXPORT_SYMBOL_GPL(bio_trim);
......
...@@ -1153,7 +1153,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio, ...@@ -1153,7 +1153,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
clone->bi_iter.bi_size = to_bytes(len); clone->bi_iter.bi_size = to_bytes(len);
if (unlikely(bio_integrity(bio) != NULL)) if (unlikely(bio_integrity(bio) != NULL))
bio_integrity_trim(clone, 0, len); bio_integrity_trim(clone);
return 0; return 0;
} }
......
...@@ -728,7 +728,7 @@ extern bool bio_integrity_enabled(struct bio *bio); ...@@ -728,7 +728,7 @@ extern bool bio_integrity_enabled(struct bio *bio);
extern int bio_integrity_prep(struct bio *); extern int bio_integrity_prep(struct bio *);
extern void bio_integrity_endio(struct bio *); extern void bio_integrity_endio(struct bio *);
extern void bio_integrity_advance(struct bio *, unsigned int); extern void bio_integrity_advance(struct bio *, unsigned int);
extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); extern void bio_integrity_trim(struct bio *);
extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t); extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t);
extern int bioset_integrity_create(struct bio_set *, int); extern int bioset_integrity_create(struct bio_set *, int);
extern void bioset_integrity_free(struct bio_set *); extern void bioset_integrity_free(struct bio_set *);
...@@ -778,8 +778,7 @@ static inline void bio_integrity_advance(struct bio *bio, ...@@ -778,8 +778,7 @@ static inline void bio_integrity_advance(struct bio *bio,
return; return;
} }
static inline void bio_integrity_trim(struct bio *bio, unsigned int offset, static inline void bio_integrity_trim(struct bio *bio)
unsigned int sectors)
{ {
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment