linux-scsi.vger.kernel.org archive mirror
 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 12/14] block: Add specific data integrity errors
Date: Wed, 28 May 2014 23:28:46 -0400	[thread overview]
Message-ID: <1401334128-15499-13-git-send-email-martin.petersen@oracle.com> (raw)
In-Reply-To: <1401334128-15499-1-git-send-email-martin.petersen@oracle.com>

Introduce a set of error codes that can be used by the block integrity
subsystem to signal which class of error was encountered by either the
I/O controller or the storage device.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 block/blk-core.c                 | 12 ++++++++++++
 drivers/md/dm-mpath.c            |  9 +++++++++
 drivers/scsi/scsi_lib.c          | 30 ++++++++++++++++++++++++++++--
 include/uapi/asm-generic/errno.h | 11 +++++++++++
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 5b6f768a7c01..9e8b9649baf7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2428,6 +2428,18 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
 		case -ENODATA:
 			error_type = "critical medium";
 			break;
+		case -ECTRLGRD:
+		case -ECTRLAPP:
+		case -ECTRLREF:
+		case -EDISKGRD:
+		case -EDISKAPP:
+		case -EDISKREF:
+		case -EKERNGRD:
+		case -EKERNAPP:
+		case -EKERNREF:
+		case -EILSEQ:
+			error_type = "data integrity";
+			break;
 		case -EIO:
 		default:
 			error_type = "I/O";
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index aa009e865871..a8756cdd1002 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1208,6 +1208,15 @@ static int noretry_error(int error)
 	case -EOPNOTSUPP:
 	case -EREMOTEIO:
 	case -EILSEQ:
+	case -ECTRLGRD:
+	case -ECTRLAPP:
+	case -ECTRLREF:
+	case -EDISKGRD:
+	case -EDISKAPP:
+	case -EDISKREF:
+	case -EKERNGRD:
+	case -EKERNAPP:
+	case -EKERNREF:
 	case -ENODATA:
 	case -ENOSPC:
 		return 1;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 3cc82d3dec78..4f369d6f1162 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -892,7 +892,20 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 			} else if (sshdr.asc == 0x10) /* DIX */ {
 				description = "Host Data Integrity Failure";
 				action = ACTION_FAIL;
-				error = -EILSEQ;
+				switch (sshdr.ascq) {
+				case 0x1:
+					error = -ECTRLGRD;
+					break;
+				case 0x2:
+					error = -ECTRLAPP;
+					break;
+				case 0x3:
+					error = -ECTRLREF;
+					break;
+				default:
+					error = -EILSEQ;
+					break;
+				}
 			/* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */
 			} else if (sshdr.asc == 0x20 || sshdr.asc == 0x24) {
 				switch (cmd->cmnd[0]) {
@@ -920,7 +933,20 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 			action = ACTION_FAIL;
 			if (sshdr.asc == 0x10) { /* DIF */
 				description = "Target Data Integrity Failure";
-				error = -EILSEQ;
+				switch (sshdr.ascq) {
+				case 0x1:
+					error = -EDISKGRD;
+					break;
+				case 0x2:
+					error = -EDISKAPP;
+					break;
+				case 0x3:
+					error = -EDISKREF;
+					break;
+				default:
+					error = -EILSEQ;
+					break;
+				}
 			}
 			break;
 		case NOT_READY:
diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
index 1e1ea6e6e7a5..d89af4ba1e04 100644
--- a/include/uapi/asm-generic/errno.h
+++ b/include/uapi/asm-generic/errno.h
@@ -110,4 +110,15 @@
 
 #define EHWPOISON	133	/* Memory page has hardware error */
 
+/* data integrity errors */
+#define ECTRLGRD	134	/* I/O controller detected guard tag error */
+#define ECTRLAPP	135	/* I/O controller detected app tag error */
+#define ECTRLREF	136	/* I/O controller detected ref tag error */
+#define EDISKGRD	137	/* Storage device detected guard tag error */
+#define EDISKAPP	138	/* Storage device detected app tag error */
+#define EDISKREF	139	/* Storage device detected ref tag error */
+#define EKERNGRD	140	/* Kernel detected guard tag error */
+#define EKERNAPP	141	/* Kernel detected app tag error */
+#define EKERNREF	142	/* Kernel detected ref tag error */
+
 #endif
-- 
1.9.0


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

Thread overview: 47+ 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 ` [PATCH 08/14] block: Add a disk flag to block integrity profile Martin K. Petersen
2014-06-11 16:48   ` 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 ` Martin K. Petersen [this message]
2014-06-11 16:54   ` [PATCH 12/14] block: Add specific data integrity errors Christoph Hellwig
     [not found]     ` <20140611165455.GG9511-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
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-13-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).