Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: Add a disk flag to block integrity profile

So far we have relied on the app tag size to determine whether a disk
has been formatted with T10 protection information or not. However, not
all target devices provide application tag storage.

Add a flag to the block integrity profile that indicates whether the
disk has been formatted with protection information.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Sagi Grimberg <sagig@dev.mellanox.co.il>
Signed-off-by: Jens Axboe <axboe@fb.com>

authored by

Martin K. Petersen and committed by
Jens Axboe
3aec2f41 8288f496

+28 -1
+8
Documentation/ABI/testing/sysfs-block
··· 53 53 512 bytes of data. 54 54 55 55 56 + What: /sys/block/<disk>/integrity/device_is_integrity_capable 57 + Date: July 2014 58 + Contact: Martin K. Petersen <martin.petersen@oracle.com> 59 + Description: 60 + Indicates whether a storage device is capable of storing 61 + integrity metadata. Set if the device is T10 PI-capable. 62 + 63 + 56 64 What: /sys/block/<disk>/integrity/write_generate 57 65 Date: June 2008 58 66 Contact: Martin K. Petersen <martin.petersen@oracle.com>
+12
block/blk-integrity.c
··· 307 307 return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_GENERATE) != 0); 308 308 } 309 309 310 + static ssize_t integrity_device_show(struct blk_integrity *bi, char *page) 311 + { 312 + return sprintf(page, "%u\n", 313 + (bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE) != 0); 314 + } 315 + 310 316 static struct integrity_sysfs_entry integrity_format_entry = { 311 317 .attr = { .name = "format", .mode = S_IRUGO }, 312 318 .show = integrity_format_show, ··· 335 329 .store = integrity_generate_store, 336 330 }; 337 331 332 + static struct integrity_sysfs_entry integrity_device_entry = { 333 + .attr = { .name = "device_is_integrity_capable", .mode = S_IRUGO }, 334 + .show = integrity_device_show, 335 + }; 336 + 338 337 static struct attribute *integrity_attrs[] = { 339 338 &integrity_format_entry.attr, 340 339 &integrity_tag_size_entry.attr, 341 340 &integrity_verify_entry.attr, 342 341 &integrity_generate_entry.attr, 342 + &integrity_device_entry.attr, 343 343 NULL, 344 344 }; 345 345
+7 -1
drivers/scsi/sd_dif.c
··· 270 270 "Enabling DIX %s protection\n", disk->integrity->name); 271 271 272 272 /* Signal to block layer that we support sector tagging */ 273 - if (dif && type && sdkp->ATO) { 273 + if (dif && type) { 274 + 275 + disk->integrity->flags |= BLK_INTEGRITY_DEVICE_CAPABLE; 276 + 277 + if (!sdkp) 278 + return; 279 + 274 280 if (type == SD_DIF_TYPE3_PROTECTION) 275 281 disk->integrity->tag_size = sizeof(u16) + sizeof(u32); 276 282 else
+1
include/linux/blkdev.h
··· 1461 1461 enum blk_integrity_flags { 1462 1462 BLK_INTEGRITY_VERIFY = 1 << 0, 1463 1463 BLK_INTEGRITY_GENERATE = 1 << 1, 1464 + BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2, 1464 1465 }; 1465 1466 1466 1467 struct blk_integrity_iter {