]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: core: Add scsi_prot_ref_tag() helper
authorMartin K. Petersen <martin.petersen@oracle.com>
Wed, 9 Jun 2021 03:39:15 +0000 (23:39 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 21 Jul 2021 02:08:55 +0000 (22:08 -0400)
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.

Link: https://lore.kernel.org/r/20210609033929.3815-2-martin.petersen@oracle.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Message-Id: <20210609033929.3815-2-martin.petersen@oracle.com>

include/scsi/scsi_cmnd.h

index 779a59fe8676ddac75935194261215a03a37a689..301b9cd4ddd0d6364c01a3cd558610f8175ca7d1 100644 (file)
@@ -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;