diff mbox series

[01/15] scsi: core: Add scsi_prot_ref_tag() helper

Message ID 20210609033929.3815-2-martin.petersen@oracle.com (mailing list archive)
State Deferred
Headers show
Series Subject: Protection information and block size cleanup | expand

Commit Message

Martin K. Petersen June 9, 2021, 3:39 a.m. UTC
We are about to remove the request pointer from struct scsi_cmnd and
that will complicate getting to the ref_tag via t10_pi_ref_tag() in
the various drivers. Introduce a helper function to retrieve the
reference tag so drivers will not have to worry about the details.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 include/scsi/scsi_cmnd.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Bart Van Assche June 9, 2021, 7:55 p.m. UTC | #1
On 6/8/21 8:39 PM, Martin K. Petersen wrote:
> We are about to remove the request pointer from struct scsi_cmnd and
> that will complicate getting to the ref_tag via t10_pi_ref_tag() in
> the various drivers. Introduce a helper function to retrieve the
> reference tag so drivers will not have to worry about the details.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> ---
>  include/scsi/scsi_cmnd.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 779a59fe8676..301b9cd4ddd0 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -287,6 +287,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
>  	return blk_rq_pos(scmd->request);
>  }
>  
> +static inline u32 scsi_prot_ref_tag(struct scsi_cmnd *scmd)
> +{
> +	struct request *rq = blk_mq_rq_from_pdu(scmd);
> +
> +	return t10_pi_ref_tag(rq);
> +}
> +
>  static inline unsigned int scsi_prot_interval(struct scsi_cmnd *scmd)
>  {
>  	return scmd->device->sector_size;

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Benjamin Block June 14, 2021, 2:33 p.m. UTC | #2
On Tue, Jun 08, 2021 at 11:39:15PM -0400, Martin K. Petersen wrote:
> We are about to remove the request pointer from struct scsi_cmnd and
> that will complicate getting to the ref_tag via t10_pi_ref_tag() in
> the various drivers. Introduce a helper function to retrieve the
> reference tag so drivers will not have to worry about the details.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> ---
>  include/scsi/scsi_cmnd.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 779a59fe8676..301b9cd4ddd0 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -287,6 +287,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
>  	return blk_rq_pos(scmd->request);
>  }
>  
> +static inline u32 scsi_prot_ref_tag(struct scsi_cmnd *scmd)
> +{
> +	struct request *rq = blk_mq_rq_from_pdu(scmd);
> +
> +	return t10_pi_ref_tag(rq);
> +}
> +
>  static inline unsigned int scsi_prot_interval(struct scsi_cmnd *scmd)
>  {
>  	return scmd->device->sector_size;

Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
diff mbox series

Patch

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 779a59fe8676..301b9cd4ddd0 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -287,6 +287,13 @@  static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
 	return blk_rq_pos(scmd->request);
 }
 
+static inline u32 scsi_prot_ref_tag(struct scsi_cmnd *scmd)
+{
+	struct request *rq = blk_mq_rq_from_pdu(scmd);
+
+	return t10_pi_ref_tag(rq);
+}
+
 static inline unsigned int scsi_prot_interval(struct scsi_cmnd *scmd)
 {
 	return scmd->device->sector_size;