From: Christoph Hellwig <hch@infradead.org>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] t10-pi: reduce ref tag code duplication
Date: Sun, 5 Apr 2026 23:24:57 -0700 [thread overview]
Message-ID: <adNRuW8uVwHh2RIW@infradead.org> (raw)
In-Reply-To: <20260403185101.2172135-1-csander@purestorage.com>
On Fri, Apr 03, 2026 at 12:51:00PM -0600, Caleb Sander Mateos wrote:
> 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>
> ---
> include/linux/t10-pi.h | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/t10-pi.h b/include/linux/t10-pi.h
> index 2c59fe3efcd4..c6fe5db47c7a 100644
> --- a/include/linux/t10-pi.h
> +++ b/include/linux/t10-pi.h
> @@ -35,18 +35,23 @@ struct t10_pi_tuple {
> };
>
> #define T10_PI_APP_ESCAPE cpu_to_be16(0xffff)
> #define T10_PI_REF_ESCAPE cpu_to_be32(0xffffffff)
>
> -static inline u32 t10_pi_ref_tag(struct request *rq)
> +static inline u64 full_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 blk_rq_pos(rq) >> (shift - SECTOR_SHIFT);
> +}
This should probably move abouve the struct t10_pi_tuple definition
so that we keep clear blocks for classic vs extended PI.
> +
> +static inline u32 t10_pi_ref_tag(struct request *rq)
> +{
> + return full_pi_ref_tag(rq) & 0xffffffff;
Use lower_32_bits here to make it more clear and mirror the ext version?
Otherwise looks good.
prev parent reply other threads:[~2026-04-06 6:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 18:51 [PATCH] t10-pi: reduce ref tag code duplication Caleb Sander Mateos
2026-04-05 23:43 ` Anuj gupta
2026-04-06 6:24 ` Christoph Hellwig [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adNRuW8uVwHh2RIW@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox