[stgt] [PATCH 3/3] Return INFO as the offset of the first miscompare for COMPARE_AND_WRITE
Ronnie Sahlberg
ronniesahlberg at gmail.com
Fri Dec 7 05:01:05 CET 2012
If a CAW command fails due to a data mismatch then we should flag
the VALID bit to 1 in the first byte of sense data :
>From SPC:
A VALID bit set to one indicates the INFORMATION field contains valid
information as defined in this standard or a command standard.
And se set the information field to the byte offset of the first byte where
miscompare happened.
>From SBC COMPARE_AND_WRITE:
The offset from the start of the Data-Out Buffer to the first byte of
data that did not match shall be returned in the INFORMATION field of
the sense data, and the VALID bit shall be set to one.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
---
usr/bs_rdwr.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/usr/bs_rdwr.c b/usr/bs_rdwr.c
index c9ab48d..d55f7f5 100644
--- a/usr/bs_rdwr.c
+++ b/usr/bs_rdwr.c
@@ -125,7 +125,6 @@ static void bs_rdwr_request(struct scsi_cmd *cmd)
}
if (memcmp(scsi_get_out_buffer(cmd), tmpbuf, length)) {
- uint32_t pos = 0;
char *spos = scsi_get_out_buffer(cmd);
char *dpos = tmpbuf;
@@ -135,10 +134,10 @@ static void bs_rdwr_request(struct scsi_cmd *cmd)
* comparasion to find out at which offset the
* data differs.
*/
- for (pos = 0; pos < length && *spos++ == *dpos++;
- pos++)
+ for (info = 0; info < length && *spos++ == *dpos++;
+ info++)
;
- info = pos;
+
result = SAM_STAT_CHECK_CONDITION;
key = MISCOMPARE;
asc = ASC_MISCOMPARE_DURING_VERIFY_OPERATION;
@@ -356,6 +355,8 @@ verify:
eprintf("io error %p %x %d %d %" PRIu64 ", %m\n",
cmd, cmd->scb[0], ret, length, offset);
sense_data_build(cmd, key, asc);
+ if (info != 0)
+ sense_data_add_info(cmd, info);
}
}
--
1.7.3.1
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list