|
Paolo Bonzini |
0fb2b2 |
From: Fam Zheng <famz@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Date: Mon, 21 Aug 2017 22:10:06 +0800
|
|
|
59eb7a |
Subject: [PATCH] scsi: Improve scsi_sense_to_errno
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
Tweak the errno mapping to return more accurate/appropriate values.
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Message-Id: <20170821141008.19383-3-famz@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
---
|
|
Paolo Bonzini |
0fb2b2 |
util/scsi.c | 16 ++++++++++++----
|
|
Paolo Bonzini |
0fb2b2 |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
diff --git a/util/scsi.c b/util/scsi.c
|
|
Paolo Bonzini |
0fb2b2 |
index a6710799fc..472eb5bea5 100644
|
|
Paolo Bonzini |
0fb2b2 |
--- a/util/scsi.c
|
|
Paolo Bonzini |
0fb2b2 |
+++ b/util/scsi.c
|
|
Paolo Bonzini |
0fb2b2 |
@@ -18,13 +18,16 @@
|
|
Paolo Bonzini |
0fb2b2 |
int scsi_sense_to_errno(int key, int asc, int ascq)
|
|
Paolo Bonzini |
0fb2b2 |
{
|
|
Paolo Bonzini |
0fb2b2 |
switch (key) {
|
|
Paolo Bonzini |
0fb2b2 |
- case 0x02: /* NOT READY */
|
|
Paolo Bonzini |
0fb2b2 |
- return EBUSY;
|
|
Paolo Bonzini |
0fb2b2 |
- case 0x07: /* DATA PROTECTION */
|
|
Paolo Bonzini |
0fb2b2 |
- return EACCES;
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x00: /* NO SENSE */
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x01: /* RECOVERED ERROR */
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x06: /* UNIT ATTENTION */
|
|
Paolo Bonzini |
0fb2b2 |
+ /* These sense keys are not errors */
|
|
Paolo Bonzini |
0fb2b2 |
+ return 0;
|
|
Paolo Bonzini |
0fb2b2 |
case 0x0b: /* COMMAND ABORTED */
|
|
Paolo Bonzini |
0fb2b2 |
return ECANCELED;
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x02: /* NOT READY */
|
|
Paolo Bonzini |
0fb2b2 |
case 0x05: /* ILLEGAL REQUEST */
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x07: /* DATA PROTECTION */
|
|
Paolo Bonzini |
0fb2b2 |
/* Parse ASCQ */
|
|
Paolo Bonzini |
0fb2b2 |
break;
|
|
Paolo Bonzini |
0fb2b2 |
default:
|
|
Paolo Bonzini |
0fb2b2 |
@@ -37,6 +40,7 @@ int scsi_sense_to_errno(int key, int asc, int ascq)
|
|
Paolo Bonzini |
0fb2b2 |
case 0x2600: /* INVALID FIELD IN PARAMETER LIST */
|
|
Paolo Bonzini |
0fb2b2 |
return EINVAL;
|
|
Paolo Bonzini |
0fb2b2 |
case 0x2100: /* LBA OUT OF RANGE */
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x2707: /* SPACE ALLOC FAILED */
|
|
Paolo Bonzini |
0fb2b2 |
return ENOSPC;
|
|
Paolo Bonzini |
0fb2b2 |
case 0x2500: /* LOGICAL UNIT NOT SUPPORTED */
|
|
Paolo Bonzini |
0fb2b2 |
return ENOTSUP;
|
|
Paolo Bonzini |
0fb2b2 |
@@ -46,6 +50,10 @@ int scsi_sense_to_errno(int key, int asc, int ascq)
|
|
Paolo Bonzini |
0fb2b2 |
return ENOMEDIUM;
|
|
Paolo Bonzini |
0fb2b2 |
case 0x2700: /* WRITE PROTECTED */
|
|
Paolo Bonzini |
0fb2b2 |
return EACCES;
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x0401: /* NOT READY, IN PROGRESS OF BECOMING READY */
|
|
Paolo Bonzini |
0fb2b2 |
+ return EAGAIN;
|
|
Paolo Bonzini |
0fb2b2 |
+ case 0x0402: /* NOT READY, INITIALIZING COMMAND REQUIRED */
|
|
Paolo Bonzini |
0fb2b2 |
+ return ENOTCONN;
|
|
Paolo Bonzini |
0fb2b2 |
default:
|
|
Paolo Bonzini |
0fb2b2 |
return EIO;
|
|
Paolo Bonzini |
0fb2b2 |
}
|