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 <csander@purestorage.com> Reviewed-by: Anuj Gupta <anuj20.g@samsung.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260415210847.1730016-1-csander@purestorage.com Signed-off-by: Jens Axboe <axboe@kernel.dk>master
parent
64b437c4a9
commit
2f50154619
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <linux/types.h>
|
||||
#include <linux/blk-mq.h>
|
||||
#include <linux/wordpart.h>
|
||||
|
||||
/*
|
||||
* A T10 PI-capable target device can be formatted with different
|
||||
|
|
@ -25,6 +26,16 @@ enum t10_dif_type {
|
|||
T10_PI_TYPE3_PROTECTION = 0x3,
|
||||
};
|
||||
|
||||
static inline u64 full_pi_ref_tag(const struct request *rq)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* T10 Protection Information tuple.
|
||||
*/
|
||||
|
|
@ -39,12 +50,7 @@ struct t10_pi_tuple {
|
|||
|
||||
static inline u32 t10_pi_ref_tag(struct request *rq)
|
||||
{
|
||||
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;
|
||||
return lower_32_bits(full_pi_ref_tag(rq));
|
||||
}
|
||||
|
||||
struct crc64_pi_tuple {
|
||||
|
|
@ -64,12 +70,7 @@ static inline u64 lower_48_bits(u64 n)
|
|||
|
||||
static inline u64 ext_pi_ref_tag(struct request *rq)
|
||||
{
|
||||
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));
|
||||
return lower_48_bits(full_pi_ref_tag(rq));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue