All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: axboe@fb.com, nab@daterainc.com, sagig@dev.mellanox.co.il,
	linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH 08/14] block: Add a disk flag to block integrity profile
Date: Wed, 28 May 2014 23:28:42 -0400	[thread overview]
Message-ID: <1401334128-15499-9-git-send-email-martin.petersen@oracle.com> (raw)
In-Reply-To: <1401334128-15499-1-git-send-email-martin.petersen@oracle.com>

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>
---
 Documentation/ABI/testing/sysfs-block |  9 +++++++++
 block/blk-integrity.c                 | 11 +++++++++++
 drivers/scsi/sd_dif.c                 |  8 +++++++-
 include/linux/blkdev.h                |  1 +
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-block b/Documentation/ABI/testing/sysfs-block
index 279da08f7541..5876e163c430 100644
--- a/Documentation/ABI/testing/sysfs-block
+++ b/Documentation/ABI/testing/sysfs-block
@@ -53,6 +53,15 @@ Description:
 		512 bytes of data.
 
 
+What:		/sys/block/<disk>/integrity/disk
+Date:		February 2011
+Contact:	Martin K. Petersen <martin.petersen@oracle.com>
+Description:
+		Indicates whether a storage device is capable of
+		persistently storing integrity metadata. Set if the
+		device is T10 PI-capable.
+
+
 What:		/sys/block/<disk>/integrity/write_generate
 Date:		June 2008
 Contact:	Martin K. Petersen <martin.petersen@oracle.com>
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 95f451a3c581..8cf87655152b 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -307,6 +307,11 @@ static ssize_t integrity_generate_show(struct blk_integrity *bi, char *page)
 	return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_GENERATE) != 0);
 }
 
+static ssize_t integrity_disk_show(struct blk_integrity *bi, char *page)
+{
+	return sprintf(page, "%u\n", (bi->flags & BLK_INTEGRITY_DISK) != 0);
+}
+
 static struct integrity_sysfs_entry integrity_format_entry = {
 	.attr = { .name = "format", .mode = S_IRUGO },
 	.show = integrity_format_show,
@@ -329,11 +334,17 @@ static struct integrity_sysfs_entry integrity_generate_entry = {
 	.store = integrity_generate_store,
 };
 
+static struct integrity_sysfs_entry integrity_disk_entry = {
+	.attr = { .name = "disk", .mode = S_IRUGO },
+	.show = integrity_disk_show,
+};
+
 static struct attribute *integrity_attrs[] = {
 	&integrity_format_entry.attr,
 	&integrity_tag_size_entry.attr,
 	&integrity_verify_entry.attr,
 	&integrity_generate_entry.attr,
+	&integrity_disk_entry.attr,
 	NULL,
 };
 
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 801c41851a01..1d401f864fbe 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -270,7 +270,13 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
 		  "Enabling DIX %s protection\n", disk->integrity->name);
 
 	/* Signal to block layer that we support sector tagging */
-	if (dif && type && sdkp->ATO) {
+	if (dif && type) {
+
+		disk->integrity->flags |= BLK_INTEGRITY_DISK;
+
+		if (!sdkp)
+			return;
+
 		if (type == SD_DIF_TYPE3_PROTECTION)
 			disk->integrity->tag_size = sizeof(u16) + sizeof(u32);
 		else
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bb44630d27f8..4be0446a8817 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1431,6 +1431,7 @@ static inline uint64_t rq_io_start_time_ns(struct request *req)
 enum blk_integrity_flags {
 	BLK_INTEGRITY_VERIFY		= 1 << 0,
 	BLK_INTEGRITY_GENERATE		= 1 << 1,
+	BLK_INTEGRITY_DISK		= 1 << 2,
 };
 
 struct blk_integrity_iter {
-- 
1.9.0


  parent reply	other threads:[~2014-05-29  3:29 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-29  3:28 Data integrity update Martin K. Petersen
2014-05-29  3:28 ` [PATCH 01/14] block: Get rid of bdev_integrity_enabled() Martin K. Petersen
2014-06-11 16:31   ` Christoph Hellwig
2014-07-03  9:18     ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 02/14] block: Replace bi_integrity with bi_special Martin K. Petersen
2014-06-11 16:32   ` Christoph Hellwig
2014-06-12  0:18     ` Martin K. Petersen
2014-07-03  9:19       ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 03/14] block: Deprecate integrity tagging functions Martin K. Petersen
2014-06-11 16:33   ` Christoph Hellwig
2014-06-12  0:18     ` Martin K. Petersen
2014-05-29  3:28 ` [PATCH 04/14] block: Remove bip_buf Martin K. Petersen
2014-06-11 16:35   ` Christoph Hellwig
2014-07-03  9:21     ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 05/14] block: Deprecate the use of the term sector in the context of block integrity Martin K. Petersen
2014-06-11 16:45   ` Christoph Hellwig
2014-06-12  0:26     ` Martin K. Petersen
2014-07-03  9:35   ` Sagi Grimberg
2014-07-03 10:19     ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 06/14] block: Clean up the code used to generate and verify integrity metadata Martin K. Petersen
2014-07-03  9:40   ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 07/14] block: Add prefix to block integrity profile flags Martin K. Petersen
2014-06-11 16:46   ` Christoph Hellwig
2014-07-03  9:42   ` Sagi Grimberg
2014-05-29  3:28 ` Martin K. Petersen [this message]
2014-06-11 16:48   ` [PATCH 08/14] block: Add a disk flag to block integrity profile Christoph Hellwig
2014-06-12  1:30     ` Martin K. Petersen
2014-06-25 10:24       ` Christoph Hellwig
2014-06-25 11:49         ` Martin K. Petersen
2014-07-03  9:58           ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 09/14] block: Relocate integrity flags Martin K. Petersen
2014-06-11 16:51   ` Christoph Hellwig
2014-06-12  1:51     ` Martin K. Petersen
2014-07-03 10:03   ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 10/14] block: Integrity checksum flag Martin K. Petersen
2014-06-11 16:52   ` Christoph Hellwig
2014-06-12  2:03     ` Martin K. Petersen
2014-05-29  3:28 ` [PATCH 11/14] block: Don't merge requests if integrity flags differ Martin K. Petersen
2014-06-11 16:53   ` Christoph Hellwig
2014-07-03 10:06   ` Sagi Grimberg
2014-05-29  3:28 ` [PATCH 12/14] block: Add specific data integrity errors Martin K. Petersen
2014-06-11 16:54   ` Christoph Hellwig
2014-06-12  2:16     ` Martin K. Petersen
2014-06-12  2:16       ` Martin K. Petersen
2014-05-29  3:28 ` [PATCH 13/14] lib: Add T10 Protection Information functions Martin K. Petersen
2014-06-11 16:56   ` Christoph Hellwig
2014-06-12  2:23     ` Martin K. Petersen
2014-05-29  3:28 ` [PATCH 14/14] sd: Honor block layer integrity handling flags Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401334128-15499-9-git-send-email-martin.petersen@oracle.com \
    --to=martin.petersen@oracle.com \
    --cc=axboe@fb.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@daterainc.com \
    --cc=sagig@dev.mellanox.co.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.