summaryrefslogtreecommitdiff
path: root/include/linux/t10-pi.h
diff options
context:
space:
mode:
authorMax Gurtovoy <maxg@mellanox.com>2018-07-30 00:15:31 +0300
committerJens Axboe <axboe@kernel.dk>2018-07-30 17:27:01 +0300
commitddd0bc756983dc4d19000a4fe021b4c7f9d59aab (patch)
treec60de4ff47106f0c20b1f1beda9df7eedbdc8b86 /include/linux/t10-pi.h
parentc454edc21b12dd7d416de6c81555e87aaec9685c (diff)
downloadlinux-ddd0bc756983dc4d19000a4fe021b4c7f9d59aab.tar.xz
block: move ref_tag calculation func to the block layer
Currently this function is implemented in the scsi layer, but it's actual place should be the block layer since T10-PI is a general data integrity feature that is used in the nvme protocol as well. Suggested-by: Christoph Hellwig <hch@lst.de> Cc: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/t10-pi.h')
-rw-r--r--include/linux/t10-pi.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/t10-pi.h b/include/linux/t10-pi.h
index c6aa8a3c42ed..c40511f4e63d 100644
--- a/include/linux/t10-pi.h
+++ b/include/linux/t10-pi.h
@@ -37,6 +37,16 @@ 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)
+{
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+ return blk_rq_pos(rq) >>
+ (rq->q->integrity.interval_exp - 9) & 0xffffffff;
+#else
+ return -1U;
+#endif
+}
+
extern const struct blk_integrity_profile t10_pi_type1_crc;
extern const struct blk_integrity_profile t10_pi_type1_ip;
extern const struct blk_integrity_profile t10_pi_type3_crc;