diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2018-12-05 04:58:33 +0300 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-12-08 06:39:46 +0300 |
commit | 60a89a3ce0cce515dc663bc1b45ac89202ad6c79 (patch) | |
tree | 1965de161eed04cc1e72eb114b5889e943a4c9fb /include/linux/t10-pi.h | |
parent | 9ae4f8420ed7be4b13c96600e3568c144d101a23 (diff) | |
download | linux-60a89a3ce0cce515dc663bc1b45ac89202ad6c79.tar.xz |
scsi: t10-pi: Return correct ref tag when queue has no integrity profile
Commit ddd0bc756983 ("block: move ref_tag calculation func to the block
layer") moved ref tag calculation from SCSI to a library function. However,
this change broke returning the correct ref tag for devices operating in
DIF mode since these do not have an associated block integrity profile.
This in turn caused read/write failures on PI-formatted disks attached to
an mpt3sas controller.
Fixes: ddd0bc756983 ("block: move ref_tag calculation func to the block layer")
Cc: stable@vger.kernel.org # 4.19+
Reported-by: John Garry <john.garry@huawei.com>
Tested-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'include/linux/t10-pi.h')
-rw-r--r-- | include/linux/t10-pi.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/include/linux/t10-pi.h b/include/linux/t10-pi.h index b9626aa7e90c..3e2a80cc7b56 100644 --- a/include/linux/t10-pi.h +++ b/include/linux/t10-pi.h @@ -39,12 +39,13 @@ struct t10_pi_tuple { static inline u32 t10_pi_ref_tag(struct request *rq) { + unsigned int shift = ilog2(queue_logical_block_size(rq->q)); + #ifdef CONFIG_BLK_DEV_INTEGRITY - return blk_rq_pos(rq) >> - (rq->q->integrity.interval_exp - 9) & 0xffffffff; -#else - return -1U; + if (rq->q->integrity.interval_exp) + shift = rq->q->integrity.interval_exp; #endif + return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT) & 0xffffffff; } extern const struct blk_integrity_profile t10_pi_type1_crc; |