Re: [PATCH 10/14] block: Integrity checksum flag

2014-06-11 Thread Christoph Hellwig
On Wed, May 28, 2014 at 11:28:44PM -0400, Martin K. Petersen wrote:
 Make the choice of checksum a per-I/O property by introducing a flag
 that can be inspected by the SCSI layer.

Why?

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/14] block: Integrity checksum flag

2014-06-11 Thread Martin K. Petersen
 Christoph == Christoph Hellwig h...@infradead.org writes:

 Make the choice of checksum a per-I/O property by introducing a flag
 that can be inspected by the SCSI layer.

Christoph Why?

First of all it's desirable to be able to use both IP and CRC checksums
without having to unload the HBA driver.

Also, there are some corner cases where you have to force the use of CRC
guard tag even when the HBA supports IP checksums. If you are doing
recovery and need to read a disk block with bad PI, for instance, you
must be able to tell the HBA to pass the CRC through verbatim instead of
attempting to convert it to IP checksum.

Another example is qualification tooling that needs to be able to write
a block with bad PI out to storage. In that case we also have to tell
the HBA to ignore checking the PI and that it shouldn't attempt a
checksum conversion.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/14] block: Integrity checksum flag

2014-05-28 Thread Martin K. Petersen
Make the choice of checksum a per-I/O property by introducing a flag
that can be inspected by the SCSI layer.

Signed-off-by: Martin K. Petersen martin.peter...@oracle.com
---
 block/bio-integrity.c  | 3 +++
 drivers/scsi/sd_dif.c  | 6 --
 include/linux/bio.h| 1 +
 include/linux/blkdev.h | 1 +
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 877bce028766..4eb7893a7559 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -303,6 +303,9 @@ int bio_integrity_prep(struct bio *bio)
bip-bip_iter.bi_size = len;
bip_set_seed(bip, bio-bi_iter.bi_sector);
 
+   if (bi-flags  BLK_INTEGRITY_IP_CHECKSUM)
+   bip_set_flag(bip, BIP_IP_CHECKSUM);
+
/* Map it */
offset = offset_in_page(buf);
for (i = 0 ; i  nr_pages ; i++) {
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 95d5cb806f58..033d30d37952 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -255,12 +255,14 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
return;
 
/* Enable DMA of protection information */
-   if (scsi_host_get_guard(sdkp-device-host)  SHOST_DIX_GUARD_IP)
+   if (scsi_host_get_guard(sdkp-device-host)  SHOST_DIX_GUARD_IP) {
if (type == SD_DIF_TYPE3_PROTECTION)
blk_integrity_register(disk, dif_type3_integrity_ip);
else
blk_integrity_register(disk, dif_type1_integrity_ip);
-   else
+
+   disk-integrity-flags |= BLK_INTEGRITY_IP_CHECKSUM;
+   } else
if (type == SD_DIF_TYPE3_PROTECTION)
blk_integrity_register(disk, dif_type3_integrity_crc);
else
diff --git a/include/linux/bio.h b/include/linux/bio.h
index adc806325c36..83e4725f6aca 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -309,6 +309,7 @@ enum bip_flags {
BIP_MAPPED_INTEGRITY,   /* integrity metadata has been remapped */
BIP_CTRL_NOCHECK,   /* disable controller integrity checking */
BIP_DISK_NOCHECK,   /* disable disk integrity checking */
+   BIP_IP_CHECKSUM,/* IP checksum */
 };
 
 static inline bool bip_get_flag(struct bio_integrity_payload *bip,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4be0446a8817..9bf6f761f1ac 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1432,6 +1432,7 @@ enum blk_integrity_flags {
BLK_INTEGRITY_VERIFY= 1  0,
BLK_INTEGRITY_GENERATE  = 1  1,
BLK_INTEGRITY_DISK  = 1  2,
+   BLK_INTEGRITY_IP_CHECKSUM   = 1  3,
 };
 
 struct blk_integrity_iter {
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html