diff mbox series

[2/3] block: don't remap ref tag for T10 PI type 0

Message ID 1567701836-29725-2-git-send-email-maxg@mellanox.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/3] block: centralize PI remapping logic to the block layer | expand

Commit Message

Max Gurtovoy Sept. 5, 2019, 4:43 p.m. UTC
Only type 1 and type 2 have a reference tag by definition.

Suggested-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
---
 block/t10-pi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Sept. 5, 2019, 6:04 p.m. UTC | #1
> @@ -186,7 +186,8 @@ void t10_pi_prepare(struct request *rq)
>  	u32 ref_tag = t10_pi_ref_tag(rq);
>  	struct bio *bio;
>  
> -	if (rq->rq_disk->protection_type == T10_PI_TYPE3_PROTECTION)
> +	if (rq->rq_disk->protection_type == T10_PI_TYPE0_PROTECTION ||
> +	    rq->rq_disk->protection_type == T10_PI_TYPE3_PROTECTION)

Maybe just check for the ones we want to remap instead.  And add
a little helper

stastic inline bool blk_integrity_need_remap(struct gendisk *disk)
{
	return disk->protection_type == T10_PI_TYPE1_PROTECTION ||
		disk->protection_type == T10_PI_TYPE2_PROTECTION;
}
diff mbox series

Patch

diff --git a/block/t10-pi.c b/block/t10-pi.c
index 7d9a151..088c3c7 100644
--- a/block/t10-pi.c
+++ b/block/t10-pi.c
@@ -178,7 +178,7 @@  static blk_status_t t10_pi_type3_verify_ip(struct blk_integrity_iter *iter)
  * likely to be different. Remap protection information to match the
  * physical LBA.
  *
- * Type 3 does not have a reference tag so no remapping is required.
+ * Types 0 and 3 don't have a reference tag so no remapping is required.
  */
 void t10_pi_prepare(struct request *rq)
 {
@@ -186,7 +186,8 @@  void t10_pi_prepare(struct request *rq)
 	u32 ref_tag = t10_pi_ref_tag(rq);
 	struct bio *bio;
 
-	if (rq->rq_disk->protection_type == T10_PI_TYPE3_PROTECTION)
+	if (rq->rq_disk->protection_type == T10_PI_TYPE0_PROTECTION ||
+	    rq->rq_disk->protection_type == T10_PI_TYPE3_PROTECTION)
 		return;
 
 	__rq_for_each_bio(bio, rq) {
@@ -234,7 +235,7 @@  void t10_pi_prepare(struct request *rq)
  * to the device, we should remap it back to virtual values expected by the
  * block layer.
  *
- * Type 3 does not have a reference tag so no remapping is required.
+ * Types 0 and 3 don't have a reference tag so no remapping is required.
  */
 void t10_pi_complete(struct request *rq, unsigned int nr_bytes)
 {
@@ -243,7 +244,8 @@  void t10_pi_complete(struct request *rq, unsigned int nr_bytes)
 	u32 ref_tag = t10_pi_ref_tag(rq);
 	struct bio *bio;
 
-	if (rq->rq_disk->protection_type == T10_PI_TYPE3_PROTECTION)
+	if (rq->rq_disk->protection_type == T10_PI_TYPE0_PROTECTION ||
+	    rq->rq_disk->protection_type == T10_PI_TYPE3_PROTECTION)
 		return;
 
 	__rq_for_each_bio(bio, rq) {