Skip to content

Commit d695d1d

Browse files
calebsanderkawasaki
authored andcommitted
t10-pi: reduce ref tag code duplication
t10_pi_ref_tag() and ext_pi_ref_tag() are identical except for the final truncation of the ref tag to 32 or 48 bits. Factor out a helper full_pi_ref_tag() to return the untruncated ref tag and use it in t10_pi_ref_tag() and ext_pi_ref_tag(). Signed-off-by: Caleb Sander Mateos <[email protected]> Reviewed-by: Anuj Gupta <[email protected]>
1 parent 931d9b0 commit d695d1d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

include/linux/t10-pi.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ struct t10_pi_tuple {
3737
#define T10_PI_APP_ESCAPE cpu_to_be16(0xffff)
3838
#define T10_PI_REF_ESCAPE cpu_to_be32(0xffffffff)
3939

40-
static inline u32 t10_pi_ref_tag(struct request *rq)
40+
static inline u64 full_pi_ref_tag(struct request *rq)
4141
{
4242
unsigned int shift = ilog2(queue_logical_block_size(rq->q));
4343

4444
if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
4545
rq->q->limits.integrity.interval_exp)
4646
shift = rq->q->limits.integrity.interval_exp;
47-
return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT) & 0xffffffff;
47+
return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT);
48+
}
49+
50+
static inline u32 t10_pi_ref_tag(struct request *rq)
51+
{
52+
return full_pi_ref_tag(rq) & 0xffffffff;
4853
}
4954

5055
struct crc64_pi_tuple {
@@ -64,12 +69,7 @@ static inline u64 lower_48_bits(u64 n)
6469

6570
static inline u64 ext_pi_ref_tag(struct request *rq)
6671
{
67-
unsigned int shift = ilog2(queue_logical_block_size(rq->q));
68-
69-
if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
70-
rq->q->limits.integrity.interval_exp)
71-
shift = rq->q->limits.integrity.interval_exp;
72-
return lower_48_bits(blk_rq_pos(rq) >> (shift - SECTOR_SHIFT));
72+
return lower_48_bits(full_pi_ref_tag(rq));
7373
}
7474

7575
#endif

0 commit comments

Comments
 (0)