3.16.62-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Greg Edwards gedwards@ddn.com
commit 359f642700f2ff05d9c94cd9216c97af7b8e9553 upstream.
This allows bio_integrity_bytes() to be called from drivers instead of open coding it.
Acked-by: Martin K. Petersen martin.petersen@oracle.com Signed-off-by: Greg Edwards gedwards@ddn.com Signed-off-by: Jens Axboe axboe@kernel.dk [bwh: Backported to 3.16: bio_integrity_intervals() was called bio_integrity_hw_sectors() and had a different implementation. Move it without renaming.] Signed-off-by: Ben Hutchings ben@decadent.org.uk --- block/bio-integrity.c | 22 ---------------------- include/linux/blkdev.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 22 deletions(-)
--- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -194,32 +194,6 @@ int bio_integrity_enabled(struct bio *bi EXPORT_SYMBOL(bio_integrity_enabled);
/** - * bio_integrity_hw_sectors - Convert 512b sectors to hardware ditto - * @bi: blk_integrity profile for device - * @sectors: Number of 512 sectors to convert - * - * Description: The block layer calculates everything in 512 byte - * sectors but integrity metadata is done in terms of the hardware - * sector size of the storage device. Convert the block layer sectors - * to physical sectors. - */ -static inline unsigned int bio_integrity_hw_sectors(struct blk_integrity *bi, - unsigned int sectors) -{ - /* At this point there are only 512b or 4096b DIF/EPP devices */ - if (bi->sector_size == 4096) - return sectors >>= 3; - - return sectors; -} - -static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, - unsigned int sectors) -{ - return bio_integrity_hw_sectors(bi, sectors) * bi->tuple_size; -} - -/** * bio_integrity_tag_size - Retrieve integrity tag space * @bio: bio to inspect * --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1542,6 +1542,32 @@ queue_max_integrity_segments(struct requ return q->limits.max_integrity_segments; }
+/** + * bio_integrity_hw_sectors - Convert 512b sectors to hardware ditto + * @bi: blk_integrity profile for device + * @sectors: Number of 512 sectors to convert + * + * Description: The block layer calculates everything in 512 byte + * sectors but integrity metadata is done in terms of the hardware + * sector size of the storage device. Convert the block layer sectors + * to physical sectors. + */ +static inline unsigned int bio_integrity_hw_sectors(struct blk_integrity *bi, + unsigned int sectors) +{ + /* At this point there are only 512b or 4096b DIF/EPP devices */ + if (bi->sector_size == 4096) + return sectors >>= 3; + + return sectors; +} + +static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, + unsigned int sectors) +{ + return bio_integrity_hw_sectors(bi, sectors) * bi->tuple_size; +} + #else /* CONFIG_BLK_DEV_INTEGRITY */
struct bio; @@ -1608,6 +1634,18 @@ static inline bool blk_integrity_is_init { return 0; } + +static inline unsigned int bio_integrity_hw_sectors(struct blk_integrity *bi, + unsigned int sectors) +{ + return 0; +} + +static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, + unsigned int sectors) +{ + return 0; +}
#endif /* CONFIG_BLK_DEV_INTEGRITY */