diff options
author | Anuj Gupta <anuj20.g@samsung.com> | 2024-07-04 09:15:15 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-07-04 11:02:33 +0300 |
commit | 162e06871e6dcde861ef608e0c00a8b6a2d35d43 (patch) | |
tree | a663da2d1e6b7ad1c1690da9dda64d18ceb7d7ae | |
parent | 98d34c087249d39838874b83e17671e7d5eb1ca7 (diff) | |
download | linux-162e06871e6dcde861ef608e0c00a8b6a2d35d43.tar.xz |
block: t10-pi: Return correct ref tag when queue has no integrity profile
Commit c6e56cf6b2e7 ("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: c6e56cf6b2e7 ("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>
-rw-r--r-- | include/linux/t10-pi.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/linux/t10-pi.h b/include/linux/t10-pi.h index 1773610010eb..2c59fe3efcd4 100644 --- a/include/linux/t10-pi.h +++ b/include/linux/t10-pi.h @@ -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)); } |