Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Dmitry Monakhov and committed by
Jens Axboe
fbd08e76 309a62fa

+7 -15
+2 -9
block/bio-integrity.c
··· 433 433 /** 434 434 * bio_integrity_trim - Trim integrity vector 435 435 * @bio: bio whose integrity vector to update 436 - * @offset: offset to first data sector 437 - * @sectors: number of data sectors 438 436 * 439 437 * Description: Used to trim the integrity vector in a cloned bio. 440 - * The ivec will be advanced corresponding to 'offset' data sectors 441 - * and the length will be truncated corresponding to 'len' data 442 - * sectors. 443 438 */ 444 - void bio_integrity_trim(struct bio *bio, unsigned int offset, 445 - unsigned int sectors) 439 + void bio_integrity_trim(struct bio *bio) 446 440 { 447 441 struct bio_integrity_payload *bip = bio_integrity(bio); 448 442 struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); 449 443 450 - bio_integrity_advance(bio, offset << 9); 451 - bip->bip_iter.bi_size = bio_integrity_bytes(bi, sectors); 444 + bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio)); 452 445 } 453 446 EXPORT_SYMBOL(bio_integrity_trim); 454 447
+2 -2
block/bio.c
··· 1868 1868 split->bi_iter.bi_size = sectors << 9; 1869 1869 1870 1870 if (bio_integrity(split)) 1871 - bio_integrity_trim(split, 0, sectors); 1871 + bio_integrity_trim(split); 1872 1872 1873 1873 bio_advance(bio, split->bi_iter.bi_size); 1874 1874 ··· 1902 1902 bio->bi_iter.bi_size = size; 1903 1903 1904 1904 if (bio_integrity(bio)) 1905 - bio_integrity_trim(bio, 0, size); 1905 + bio_integrity_trim(bio); 1906 1906 1907 1907 } 1908 1908 EXPORT_SYMBOL_GPL(bio_trim);
+1 -1
drivers/md/dm.c
··· 1153 1153 clone->bi_iter.bi_size = to_bytes(len); 1154 1154 1155 1155 if (unlikely(bio_integrity(bio) != NULL)) 1156 - bio_integrity_trim(clone, 0, len); 1156 + bio_integrity_trim(clone); 1157 1157 1158 1158 return 0; 1159 1159 }
+2 -3
include/linux/bio.h
··· 728 728 extern int bio_integrity_prep(struct bio *); 729 729 extern void bio_integrity_endio(struct bio *); 730 730 extern void bio_integrity_advance(struct bio *, unsigned int); 731 - extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); 731 + extern void bio_integrity_trim(struct bio *); 732 732 extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t); 733 733 extern int bioset_integrity_create(struct bio_set *, int); 734 734 extern void bioset_integrity_free(struct bio_set *); ··· 778 778 return; 779 779 } 780 780 781 - static inline void bio_integrity_trim(struct bio *bio, unsigned int offset, 782 - unsigned int sectors) 781 + static inline void bio_integrity_trim(struct bio *bio) 783 782 { 784 783 return; 785 784 }