diff options
author | Greg Edwards <gedwards@ddn.com> | 2018-07-25 10:22:58 -0400 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-12-16 22:08:26 +0000 |
commit | ed1a4f65447b5475afaf2f13a74cddf332e3e5ad (patch) | |
tree | 9e4c7b9454d69197c34f22afe1c62a8b04c0dcdd /include | |
parent | 3090ef98dce0ade500bd2e6e71aa27db7efa3fb9 (diff) | |
download | linux-stable-ed1a4f65447b5475afaf2f13a74cddf332e3e5ad.tar.gz |
block: move bio_integrity_{intervals,bytes} into blkdev.h
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/blkdev.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 633ef252850b51..b992a89abde295 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1542,6 +1542,32 @@ queue_max_integrity_segments(struct request_queue *q) 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; @@ -1609,6 +1635,18 @@ static inline bool blk_integrity_is_initialized(struct gendisk *g) 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 */ struct block_device_operations { |