aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd_dif.c
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2015-10-21 13:19:33 -0400
committerJens Axboe <axboe@fb.com>2015-10-21 16:42:38 -0400
commit0f8087ecdeac921fc4920f1328f55c15080bc6aa (patch)
tree6027fd7061230f1488f74938b6bebf804be88376 /drivers/scsi/sd_dif.c
parentaff34e192e4eeacfb8b5ffc68e10a240f2c0c6d7 (diff)
block: Consolidate static integrity profile properties
We previously made a complete copy of a device's data integrity profile even though several of the fields inside the blk_integrity struct are pointers to fixed template entries in t10-pi.c. Split the static and per-device portions so that we can reference the template directly. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Reported-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/scsi/sd_dif.c')
-rw-r--r--drivers/scsi/sd_dif.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 5c06d292b94c..987bf392c336 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -43,6 +43,7 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
43 struct scsi_device *sdp = sdkp->device; 43 struct scsi_device *sdp = sdkp->device;
44 struct gendisk *disk = sdkp->disk; 44 struct gendisk *disk = sdkp->disk;
45 u8 type = sdkp->protection_type; 45 u8 type = sdkp->protection_type;
46 struct blk_integrity bi;
46 int dif, dix; 47 int dif, dix;
47 48
48 dif = scsi_host_dif_capable(sdp->host, type); 49 dif = scsi_host_dif_capable(sdp->host, type);
@@ -55,39 +56,43 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
55 if (!dix) 56 if (!dix)
56 return; 57 return;
57 58
59 memset(&bi, 0, sizeof(bi));
60
58 /* Enable DMA of protection information */ 61 /* Enable DMA of protection information */
59 if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP) { 62 if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP) {
60 if (type == SD_DIF_TYPE3_PROTECTION) 63 if (type == SD_DIF_TYPE3_PROTECTION)
61 blk_integrity_register(disk, &t10_pi_type3_ip); 64 bi.profile = &t10_pi_type3_ip;
62 else 65 else
63 blk_integrity_register(disk, &t10_pi_type1_ip); 66 bi.profile = &t10_pi_type1_ip;
64 67
65 disk->integrity->flags |= BLK_INTEGRITY_IP_CHECKSUM; 68 bi.flags |= BLK_INTEGRITY_IP_CHECKSUM;
66 } else 69 } else
67 if (type == SD_DIF_TYPE3_PROTECTION) 70 if (type == SD_DIF_TYPE3_PROTECTION)
68 blk_integrity_register(disk, &t10_pi_type3_crc); 71 bi.profile = &t10_pi_type3_crc;
69 else 72 else
70 blk_integrity_register(disk, &t10_pi_type1_crc); 73 bi.profile = &t10_pi_type1_crc;
71 74
75 bi.tuple_size = sizeof(struct t10_pi_tuple);
72 sd_printk(KERN_NOTICE, sdkp, 76 sd_printk(KERN_NOTICE, sdkp,
73 "Enabling DIX %s protection\n", disk->integrity->name); 77 "Enabling DIX %s protection\n", bi.profile->name);
74 78
75 /* Signal to block layer that we support sector tagging */
76 if (dif && type) { 79 if (dif && type) {
77 80 bi.flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
78 disk->integrity->flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
79 81
80 if (!sdkp->ATO) 82 if (!sdkp->ATO)
81 return; 83 goto out;
82 84
83 if (type == SD_DIF_TYPE3_PROTECTION) 85 if (type == SD_DIF_TYPE3_PROTECTION)
84 disk->integrity->tag_size = sizeof(u16) + sizeof(u32); 86 bi.tag_size = sizeof(u16) + sizeof(u32);
85 else 87 else
86 disk->integrity->tag_size = sizeof(u16); 88 bi.tag_size = sizeof(u16);
87 89
88 sd_printk(KERN_NOTICE, sdkp, "DIF application tag size %u\n", 90 sd_printk(KERN_NOTICE, sdkp, "DIF application tag size %u\n",
89 disk->integrity->tag_size); 91 bi.tag_size);
90 } 92 }
93
94out:
95 blk_integrity_register(disk, &bi);
91} 96}
92 97
93/* 98/*