|
|
4a2fec |
From 35c11f52fe8423b40d133e22150354a595fd109f Mon Sep 17 00:00:00 2001
|
|
|
4a2fec |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4a2fec |
Date: Sat, 2 Dec 2017 12:19:53 +0100
|
|
|
4a2fec |
Subject: [PATCH 27/36] qemu-pr-helper: miscellaneous fixes
|
|
|
4a2fec |
|
|
|
4a2fec |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4a2fec |
Message-id: <20171202121953.13317-18-pbonzini@redhat.com>
|
|
|
4a2fec |
Patchwork-id: 78090
|
|
|
4a2fec |
O-Subject: [RHEL7.4 qemu-kvm-rhev PATCH 17/17] qemu-pr-helper: miscellaneous fixes
|
|
|
4a2fec |
Bugzilla: 1464908
|
|
|
4a2fec |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
4a2fec |
|
|
|
4a2fec |
1) Return a generic sense if TEST UNIT READY does not provide one;
|
|
|
4a2fec |
|
|
|
4a2fec |
2) Fix two mistakes in copying from the spec.
|
|
|
4a2fec |
|
|
|
4a2fec |
Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
4a2fec |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4a2fec |
(cherry picked from commit 041a4acfdf4d9b2db60b10805aed94178dbf0463)
|
|
|
4a2fec |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
4a2fec |
---
|
|
|
4a2fec |
include/scsi/utils.h | 6 +++++-
|
|
|
4a2fec |
scsi/qemu-pr-helper.c | 30 ++++++++++++++++++++++++++----
|
|
|
4a2fec |
scsi/utils.c | 10 ++++++++++
|
|
|
4a2fec |
3 files changed, 41 insertions(+), 5 deletions(-)
|
|
|
4a2fec |
|
|
|
4a2fec |
diff --git a/include/scsi/utils.h b/include/scsi/utils.h
|
|
|
4a2fec |
index 00a4bdb..eb07e47 100644
|
|
|
4a2fec |
--- a/include/scsi/utils.h
|
|
|
4a2fec |
+++ b/include/scsi/utils.h
|
|
|
4a2fec |
@@ -76,7 +76,11 @@ extern const struct SCSISense sense_code_LUN_FAILURE;
|
|
|
4a2fec |
extern const struct SCSISense sense_code_LUN_COMM_FAILURE;
|
|
|
4a2fec |
/* Command aborted, Overlapped Commands Attempted */
|
|
|
4a2fec |
extern const struct SCSISense sense_code_OVERLAPPED_COMMANDS;
|
|
|
4a2fec |
-/* LUN not ready, Capacity data has changed */
|
|
|
4a2fec |
+/* Medium error, Unrecovered read error */
|
|
|
4a2fec |
+extern const struct SCSISense sense_code_READ_ERROR;
|
|
|
4a2fec |
+/* LUN not ready, Cause not reportable */
|
|
|
4a2fec |
+extern const struct SCSISense sense_code_NOT_READY;
|
|
|
4a2fec |
+/* Unit attention, Capacity data has changed */
|
|
|
4a2fec |
extern const struct SCSISense sense_code_CAPACITY_CHANGED;
|
|
|
4a2fec |
/* Unit attention, SCSI bus reset */
|
|
|
4a2fec |
extern const struct SCSISense sense_code_SCSI_BUS_RESET;
|
|
|
4a2fec |
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
|
|
|
4a2fec |
index 42bc2cf..4c6ca63 100644
|
|
|
4a2fec |
--- a/scsi/qemu-pr-helper.c
|
|
|
4a2fec |
+++ b/scsi/qemu-pr-helper.c
|
|
|
4a2fec |
@@ -303,6 +303,22 @@ static int is_mpath(int fd)
|
|
|
4a2fec |
return !strncmp(tgt->target_type, "multipath", DM_MAX_TYPE_NAME);
|
|
|
4a2fec |
}
|
|
|
4a2fec |
|
|
|
4a2fec |
+static SCSISense mpath_generic_sense(int r)
|
|
|
4a2fec |
+{
|
|
|
4a2fec |
+ switch (r) {
|
|
|
4a2fec |
+ case MPATH_PR_SENSE_NOT_READY:
|
|
|
4a2fec |
+ return SENSE_CODE(NOT_READY);
|
|
|
4a2fec |
+ case MPATH_PR_SENSE_MEDIUM_ERROR:
|
|
|
4a2fec |
+ return SENSE_CODE(READ_ERROR);
|
|
|
4a2fec |
+ case MPATH_PR_SENSE_HARDWARE_ERROR:
|
|
|
4a2fec |
+ return SENSE_CODE(TARGET_FAILURE);
|
|
|
4a2fec |
+ case MPATH_PR_SENSE_ABORTED_COMMAND:
|
|
|
4a2fec |
+ return SENSE_CODE(IO_ERROR);
|
|
|
4a2fec |
+ default:
|
|
|
4a2fec |
+ abort();
|
|
|
4a2fec |
+ }
|
|
|
4a2fec |
+}
|
|
|
4a2fec |
+
|
|
|
4a2fec |
static int mpath_reconstruct_sense(int fd, int r, uint8_t *sense)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
switch (r) {
|
|
|
4a2fec |
@@ -318,7 +334,13 @@ static int mpath_reconstruct_sense(int fd, int r, uint8_t *sense)
|
|
|
4a2fec |
*/
|
|
|
4a2fec |
uint8_t cdb[6] = { TEST_UNIT_READY };
|
|
|
4a2fec |
int sz = 0;
|
|
|
4a2fec |
- return do_sgio(fd, cdb, sense, NULL, &sz, SG_DXFER_NONE);
|
|
|
4a2fec |
+ int r = do_sgio(fd, cdb, sense, NULL, &sz, SG_DXFER_NONE);
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+ if (r != GOOD) {
|
|
|
4a2fec |
+ return r;
|
|
|
4a2fec |
+ }
|
|
|
4a2fec |
+ scsi_build_sense(sense, mpath_generic_sense(r));
|
|
|
4a2fec |
+ return CHECK_CONDITION;
|
|
|
4a2fec |
}
|
|
|
4a2fec |
|
|
|
4a2fec |
case MPATH_PR_SENSE_UNIT_ATTENTION:
|
|
|
4a2fec |
@@ -438,7 +460,7 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,
|
|
|
4a2fec |
memset(¶mp, 0, sizeof(paramp));
|
|
|
4a2fec |
memcpy(¶mp.key, ¶m[0], 8);
|
|
|
4a2fec |
memcpy(¶mp.sa_key, ¶m[8], 8);
|
|
|
4a2fec |
- paramp.sa_flags = param[10];
|
|
|
4a2fec |
+ paramp.sa_flags = param[20];
|
|
|
4a2fec |
if (sz > PR_OUT_FIXED_PARAM_SIZE) {
|
|
|
4a2fec |
size_t transportid_len;
|
|
|
4a2fec |
int i, j;
|
|
|
4a2fec |
@@ -467,8 +489,8 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,
|
|
|
4a2fec |
j += offsetof(struct transportid, n_port_name[8]);
|
|
|
4a2fec |
i += 24;
|
|
|
4a2fec |
break;
|
|
|
4a2fec |
- case 3:
|
|
|
4a2fec |
- case 0x43:
|
|
|
4a2fec |
+ case 5:
|
|
|
4a2fec |
+ case 0x45:
|
|
|
4a2fec |
/* iSCSI transport. */
|
|
|
4a2fec |
len = lduw_be_p(¶m[i + 2]);
|
|
|
4a2fec |
if (len > 252 || (len & 3) || i + len + 4 > transportid_len) {
|
|
|
4a2fec |
diff --git a/scsi/utils.c b/scsi/utils.c
|
|
|
4a2fec |
index 5684951..e4182a9 100644
|
|
|
4a2fec |
--- a/scsi/utils.c
|
|
|
4a2fec |
+++ b/scsi/utils.c
|
|
|
4a2fec |
@@ -211,6 +211,16 @@ const struct SCSISense sense_code_LUN_COMM_FAILURE = {
|
|
|
4a2fec |
.key = ABORTED_COMMAND, .asc = 0x08, .ascq = 0x00
|
|
|
4a2fec |
};
|
|
|
4a2fec |
|
|
|
4a2fec |
+/* Medium Error, Unrecovered read error */
|
|
|
4a2fec |
+const struct SCSISense sense_code_READ_ERROR = {
|
|
|
4a2fec |
+ .key = MEDIUM_ERROR, .asc = 0x11, .ascq = 0x00
|
|
|
4a2fec |
+};
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+/* Not ready, Cause not reportable */
|
|
|
4a2fec |
+const struct SCSISense sense_code_NOT_READY = {
|
|
|
4a2fec |
+ .key = NOT_READY, .asc = 0x04, .ascq = 0x00
|
|
|
4a2fec |
+};
|
|
|
4a2fec |
+
|
|
|
4a2fec |
/* Unit attention, Capacity data has changed */
|
|
|
4a2fec |
const struct SCSISense sense_code_CAPACITY_CHANGED = {
|
|
|
4a2fec |
.key = UNIT_ATTENTION, .asc = 0x2a, .ascq = 0x09
|
|
|
4a2fec |
--
|
|
|
4a2fec |
1.8.3.1
|
|
|
4a2fec |
|