[PATCH v2 3/6] blk-integrity: take u64 in bio_integrity_intervals()

Caleb Sander Mateos
2026-04-16T00:22:48Z

To allow bio_integrity_intervals() to convert an absolute sector to an
absolute integrity interval, use u64 for its argument and return types.
Also use SECTOR_SHIFT instead of the magic constant 9.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
---
include/linux/blk-integrity.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
index b1b530613c34..825d777c078b 100644
--- a/include/linux/blk-integrity.h
+++ b/include/linux/blk-integrity.h
@@ -64,23 +64,23 @@ queue_max_integrity_segments(const struct request_queue *q)
{
return q->limits.max_integrity_segments;
}

/**
- * bio_integrity_intervals - Return number of integrity intervals for a bio
+ * bio_integrity_intervals - Convert sectors to integrity intervals
* @bi: blk_integrity profile for device
- * @sectors: Size of the bio in 512-byte sectors
+ * @sectors: Number of 512-byte sectors
*
* Description: The block layer calculates everything in 512 byte
* sectors but integrity metadata is done in terms of the data integrity
* interval size of the storage device. Convert the block layer sectors
* to the appropriate number of integrity intervals.
*/
-static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
- unsigned int sectors)
+static inline u64 bio_integrity_intervals(const struct blk_integrity *bi,
+ u64 sectors)
{
- return sectors >> (bi->interval_exp - 9);
+ return sectors >> (bi->interval_exp - SECTOR_SHIFT);
}

static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
unsigned int sectors)
{
@@ -151,12 +151,12 @@ static inline unsigned short
queue_max_integrity_segments(const struct request_queue *q)
{
return 0;
}

-static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
- unsigned int sectors)
+static inline u64 bio_integrity_intervals(const struct blk_integrity *bi,
+ u64 sectors)
{
return 0;
}

static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
--
2.45.2