block: t10-pi: Return correct ref tag when queue has no integrity profile

Commit c6e56cf6b2 ("block: move integrity information into
queue_limits") changed the ref tag calculation logic. It would break if
there is no integrity profile. This in turn causes read/write failures
for such cases.

Fixes: c6e56cf6b2 ("block: move integrity information into queue_limits")
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Link: https://lore.kernel.org/r/20240704061515.282343-1-joshi.k@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Anuj Gupta 2024-07-04 11:45:15 +05:30 committed by Jens Axboe
parent 98d34c0872
commit 162e06871e

View File

@ -39,8 +39,11 @@ struct t10_pi_tuple {
static inline u32 t10_pi_ref_tag(struct request *rq)
{
unsigned int shift = rq->q->limits.integrity.interval_exp;
unsigned int shift = ilog2(queue_logical_block_size(rq->q));
if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
rq->q->limits.integrity.interval_exp)
shift = rq->q->limits.integrity.interval_exp;
return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT) & 0xffffffff;
}
@ -61,8 +64,11 @@ static inline u64 lower_48_bits(u64 n)
static inline u64 ext_pi_ref_tag(struct request *rq)
{
unsigned int shift = rq->q->limits.integrity.interval_exp;
unsigned int shift = ilog2(queue_logical_block_size(rq->q));
if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
rq->q->limits.integrity.interval_exp)
shift = rq->q->limits.integrity.interval_exp;
return lower_48_bits(blk_rq_pos(rq) >> (shift - SECTOR_SHIFT));
}