Re: [PATCH v4 1/3] block: move ref_tag calculation func to the block layer

Max Gurtovoy
2018-07-28T22:12:04Z

On 7/27/2018 6:38 PM, Jens Axboe wrote:
> On 7/27/18 9:21 AM, Jens Axboe wrote:
>> On 7/25/18 9:46 AM, Max Gurtovoy wrote:
>>> Currently this function is implemented in the scsi layer, but it's
>>> actual place should be the block layer since T10-PI is a general
>>> data integrity feature that is used in the nvme protocol as well.
>>
>> Applied 1-3 for 4.19.
>
> This:
>
> static inline u32 t10_pi_ref_tag(struct request *rq)
> {
> return blk_rq_pos(rq) >>
> (rq->q->integrity.interval_exp - 9) & 0xffffffff;
> }
>
> won't work for !CONFIG_BLK_DEV_INTEGRITY. I didn't want to make the
> change, but looks like it should either return -1U as we the value
> should mean nothing if BLK_DEV_INTEGRITY isn't set, or just ignore the
> shift and return blk_rq_pos(rq) & 0xffffffff.
>
> Please fixup and resend the series.
>

will this be good enough:

diff --git a/include/linux/t10-pi.h b/include/linux/t10-pi.h
index 81ae4c4..5a427c2 100644
--- a/include/linux/t10-pi.h
+++ b/include/linux/t10-pi.h
@@ -39,8 +39,12 @@ struct t10_pi_tuple {

static inline u32 t10_pi_ref_tag(struct request *rq)
{
+#ifdef CONFIG_BLK_DEV_INTEGRITY
return blk_rq_pos(rq) >>
(rq->q->integrity.interval_exp - 9) & 0xffffffff;
+#else
+ return -1U;
+#endif
}

extern const struct blk_integrity_profile t10_pi_type1_crc;