Skip to contentSkip to conversation

scsi: fix sense code for EREMOTEIO

PATCH In review Paolo Bonzini 2 participants 3 messages Mar 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: fix sense code for EREMOTEIO

SENSE_CODE(LUN_COMM_FAILURE) has an ABORTED COMMAND sense key, so it results in a retry in Linux. To ensure that EREMOTEIO is forwarded to the guest, use a HARDWARE ERROR sense key instead. Note that the code before commit d7a84021d was incorrect because it used HARDWARE_ERROR as a SCSI status, not as a sense key.

---
 scsi/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scsi/utils.c +2 -2
index 873e05aeaf..357b036671 100644
@@ -589,7 +589,7 @@ int scsi_sense_from_errno(int errno_value, SCSISense *sense)
         return TASK_SET_FULL;
 #ifdef CONFIG_LINUX
         /* These errno mapping are specific to Linux.  For more information:
-         * - scsi_decide_disposition in drivers/scsi/scsi_error.c
+         * - scsi_check_sense and scsi_decide_disposition in drivers/scsi/scsi_error.c
          * - scsi_result_to_blk_status in drivers/scsi/scsi_lib.c
          * - blk_errors[] in block/blk-core.c
          */
@@ -599,7 +599,7 @@ int scsi_sense_from_errno(int errno_value, SCSISense *sense)
         *sense = SENSE_CODE(READ_ERROR);
         return CHECK_CONDITION;
     case EREMOTEIO:
-        *sense = SENSE_CODE(LUN_COMM_FAILURE);
+        *sense = SENSE_CODE(TARGET_FAILURE);
         return CHECK_CONDITION;
 #endif
     case ENOMEDIUM:
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Paolo Bonzini

SENSE_CODE(LUN_COMM_FAILURE) has an ABORTED COMMAND sense key, so it results in a retry in Linux. To ensure that EREMOTEIO is forwarded to the guest, use a HARDWARE ERROR sense key instead. Note that the code before commit d7a84021d was incorrect because it used HARDWARE_ERROR as a SCSI status, not as a sense key.

It is not clear whether if it deserves a 'Fixes: d7a84021db8 ("scsi:
introduce scsi_sense_from_errno()")' or not...

Quoted 2 lines
Quoted 27 lines
---
 scsi/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scsi/utils.c +2 -2
index 873e05aeaf..357b036671 100644
@@ -589,7 +589,7 @@ int scsi_sense_from_errno(int errno_value, SCSISense *sense)
         return TASK_SET_FULL;
 #ifdef CONFIG_LINUX
         /* These errno mapping are specific to Linux.  For more information:
-         * - scsi_decide_disposition in drivers/scsi/scsi_error.c
+         * - scsi_check_sense and scsi_decide_disposition in drivers/scsi/scsi_error.c
          * - scsi_result_to_blk_status in drivers/scsi/scsi_lib.c
          * - blk_errors[] in block/blk-core.c
          */
@@ -599,7 +599,7 @@ int scsi_sense_from_errno(int errno_value, SCSISense *sense)
         *sense = SENSE_CODE(READ_ERROR);
         return CHECK_CONDITION;
     case EREMOTEIO:
-        *sense = SENSE_CODE(LUN_COMM_FAILURE);
+        *sense = SENSE_CODE(TARGET_FAILURE);
         return CHECK_CONDITION;
 #endif
     case ENOMEDIUM:
#2 lore raw
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 6 lines

SENSE_CODE(LUN_COMM_FAILURE) has an ABORTED COMMAND sense key, so it results in a retry in Linux. To ensure that EREMOTEIO is forwarded to the guest, use a HARDWARE ERROR sense key instead. Note that the code before commit d7a84021d was incorrect because it used HARDWARE_ERROR as a SCSI status, not as a sense key.

It is not clear whether if it deserves a 'Fixes: d7a84021db8 ("scsi:
introduce scsi_sense_from_errno()")' or not...

Yes, why not. That was in turn a bugfix but not the best.

Paolo

Quoted 4 lines
Quoted 2 lines