Skip to content

Commit aae7df5

Browse files
martinkpetersenaxboe
authored andcommitted
block: Integrity checksum flag
Make the choice of checksum a per-I/O property by introducing a flag that can be inspected by the SCSI layer. There are several reasons for this: 1. It allows us to switch choice of checksum without unloading and reloading the HBA driver. 2. During error recovery we need to be able to tell the HBA that checksums read from disk should not be verified and converted to IP checksums. 3. For error injection purposes we need to be able to write a bad guard tag to storage. Since the storage device only supports T10 CRC we need to be able to disable IP checksum conversion on the HBA. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent b1f0138 commit aae7df5

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

block/bio-integrity.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ int bio_integrity_prep(struct bio *bio)
297297
bip->bip_iter.bi_size = len;
298298
bip_set_seed(bip, bio->bi_iter.bi_sector);
299299

300+
if (bi->flags & BLK_INTEGRITY_IP_CHECKSUM)
301+
bip->bip_flags |= BIP_IP_CHECKSUM;
302+
300303
/* Map it */
301304
offset = offset_in_page(buf);
302305
for (i = 0 ; i < nr_pages ; i++) {

drivers/scsi/sd_dif.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,14 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
255255
return;
256256

257257
/* Enable DMA of protection information */
258-
if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP)
258+
if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP) {
259259
if (type == SD_DIF_TYPE3_PROTECTION)
260260
blk_integrity_register(disk, &dif_type3_integrity_ip);
261261
else
262262
blk_integrity_register(disk, &dif_type1_integrity_ip);
263-
else
263+
264+
disk->integrity->flags |= BLK_INTEGRITY_IP_CHECKSUM;
265+
} else
264266
if (type == SD_DIF_TYPE3_PROTECTION)
265267
blk_integrity_register(disk, &dif_type3_integrity_crc);
266268
else

include/linux/bio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ enum bip_flags {
328328
BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */
329329
BIP_CTRL_NOCHECK = 1 << 2, /* disable HBA integrity checking */
330330
BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */
331+
BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */
331332
};
332333

333334
static inline sector_t bip_get_seed(struct bio_integrity_payload *bip)

include/linux/blkdev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,7 @@ enum blk_integrity_flags {
14621462
BLK_INTEGRITY_VERIFY = 1 << 0,
14631463
BLK_INTEGRITY_GENERATE = 1 << 1,
14641464
BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2,
1465+
BLK_INTEGRITY_IP_CHECKSUM = 1 << 3,
14651466
};
14661467

14671468
struct blk_integrity_iter {

0 commit comments

Comments
 (0)