Skip to content

Commit 3aec2f4

Browse files
martinkpetersenaxboe
authored andcommitted
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>
1 parent 8288f49 commit 3aec2f4

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎Documentation/ABI/testing/sysfs-block‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ Description:
5353
512 bytes of data.
5454

5555

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+
5664
What: /sys/block/<disk>/integrity/write_generate
5765
Date: June 2008
5866
Contact: Martin K. Petersen <martin.petersen@oracle.com>

‎block/blk-integrity.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ static ssize_t integrity_generate_show(struct blk_integrity *bi, char *page)
307307
return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_GENERATE) != 0);
308308
}
309309

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+
310316
static struct integrity_sysfs_entry integrity_format_entry = {
311317
.attr = { .name = "format", .mode = S_IRUGO },
312318
.show = integrity_format_show,
@@ -329,11 +335,17 @@ static struct integrity_sysfs_entry integrity_generate_entry = {
329335
.store = integrity_generate_store,
330336
};
331337

338+
static struct integrity_sysfs_entry integrity_device_entry = {
339+
.attr = { .name = "device_is_integrity_capable", .mode = S_IRUGO },
340+
.show = integrity_device_show,
341+
};
342+
332343
static struct attribute *integrity_attrs[] = {
333344
&integrity_format_entry.attr,
334345
&integrity_tag_size_entry.attr,
335346
&integrity_verify_entry.attr,
336347
&integrity_generate_entry.attr,
348+
&integrity_device_entry.attr,
337349
NULL,
338350
};
339351

‎drivers/scsi/sd_dif.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,13 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
270270
"Enabling DIX %s protection\n", disk->integrity->name);
271271

272272
/* 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+
274280
if (type == SD_DIF_TYPE3_PROTECTION)
275281
disk->integrity->tag_size = sizeof(u16) + sizeof(u32);
276282
else

‎include/linux/blkdev.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,7 @@ static inline uint64_t rq_io_start_time_ns(struct request *req)
14611461
enum blk_integrity_flags {
14621462
BLK_INTEGRITY_VERIFY = 1 << 0,
14631463
BLK_INTEGRITY_GENERATE = 1 << 1,
1464+
BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2,
14641465
};
14651466

14661467
struct blk_integrity_iter {

0 commit comments

Comments
 (0)