|
|
9bac43 |
From bc3855000036c3abe2a440d3cb65a9fbd90745fb Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
Date: Sat, 2 Dec 2017 12:19:41 +0100
|
|
|
9bac43 |
Subject: [PATCH 15/36] scsi: Improve scsi_sense_to_errno
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
Message-id: <20171202121953.13317-6-pbonzini@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 78077
|
|
|
9bac43 |
O-Subject: [RHEL7.4 qemu-kvm-rhev PATCH 05/17] scsi: Improve scsi_sense_to_errno
|
|
|
9bac43 |
Bugzilla: 1464908
|
|
|
9bac43 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Tweak the errno mapping to return more accurate/appropriate values.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9bac43 |
Message-Id: <20170821141008.19383-3-famz@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit 5efa3c04483d408a03ff5f018842501a2048a51b)
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
util/scsi.c | 16 ++++++++++++----
|
|
|
9bac43 |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/util/scsi.c b/util/scsi.c
|
|
|
9bac43 |
index a671079..472eb5b 100644
|
|
|
9bac43 |
--- a/util/scsi.c
|
|
|
9bac43 |
+++ b/util/scsi.c
|
|
|
9bac43 |
@@ -18,13 +18,16 @@
|
|
|
9bac43 |
int scsi_sense_to_errno(int key, int asc, int ascq)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
switch (key) {
|
|
|
9bac43 |
- case 0x02: /* NOT READY */
|
|
|
9bac43 |
- return EBUSY;
|
|
|
9bac43 |
- case 0x07: /* DATA PROTECTION */
|
|
|
9bac43 |
- return EACCES;
|
|
|
9bac43 |
+ case 0x00: /* NO SENSE */
|
|
|
9bac43 |
+ case 0x01: /* RECOVERED ERROR */
|
|
|
9bac43 |
+ case 0x06: /* UNIT ATTENTION */
|
|
|
9bac43 |
+ /* These sense keys are not errors */
|
|
|
9bac43 |
+ return 0;
|
|
|
9bac43 |
case 0x0b: /* COMMAND ABORTED */
|
|
|
9bac43 |
return ECANCELED;
|
|
|
9bac43 |
+ case 0x02: /* NOT READY */
|
|
|
9bac43 |
case 0x05: /* ILLEGAL REQUEST */
|
|
|
9bac43 |
+ case 0x07: /* DATA PROTECTION */
|
|
|
9bac43 |
/* Parse ASCQ */
|
|
|
9bac43 |
break;
|
|
|
9bac43 |
default:
|
|
|
9bac43 |
@@ -37,6 +40,7 @@ int scsi_sense_to_errno(int key, int asc, int ascq)
|
|
|
9bac43 |
case 0x2600: /* INVALID FIELD IN PARAMETER LIST */
|
|
|
9bac43 |
return EINVAL;
|
|
|
9bac43 |
case 0x2100: /* LBA OUT OF RANGE */
|
|
|
9bac43 |
+ case 0x2707: /* SPACE ALLOC FAILED */
|
|
|
9bac43 |
return ENOSPC;
|
|
|
9bac43 |
case 0x2500: /* LOGICAL UNIT NOT SUPPORTED */
|
|
|
9bac43 |
return ENOTSUP;
|
|
|
9bac43 |
@@ -46,6 +50,10 @@ int scsi_sense_to_errno(int key, int asc, int ascq)
|
|
|
9bac43 |
return ENOMEDIUM;
|
|
|
9bac43 |
case 0x2700: /* WRITE PROTECTED */
|
|
|
9bac43 |
return EACCES;
|
|
|
9bac43 |
+ case 0x0401: /* NOT READY, IN PROGRESS OF BECOMING READY */
|
|
|
9bac43 |
+ return EAGAIN;
|
|
|
9bac43 |
+ case 0x0402: /* NOT READY, INITIALIZING COMMAND REQUIRED */
|
|
|
9bac43 |
+ return ENOTCONN;
|
|
|
9bac43 |
default:
|
|
|
9bac43 |
return EIO;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|