scsi: scsi_error: Handle power-on reset unit attention
authorHannes Reinecke <hare@suse.de>
Tue, 17 Oct 2017 07:11:24 +0000 (09:11 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 19 Oct 2017 00:55:40 +0000 (20:55 -0400)
As per SAM there is a status precedence, with any sense code 29/XX
taking second place just after an ACA ACTIVE status.  Additionally, each
target might prefer to not queue any unit attention conditions, but just
report one.  Due to the above, this will be that one with the highest
precedence.  This results in the sense code 29/XX effectively
overwriting any other unit attention.  Hence we should report the
power-on reset to userland so that it can take appropriate action.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
include/scsi/scsi_device.h

index 5086489dac97d51fe766b662e89515e90cf30d1e..d670027f598f9bbeec54c1cc735816f180cfe71e 100644 (file)
@@ -403,6 +403,12 @@ static void scsi_report_sense(struct scsi_device *sdev,
                                    "threshold.\n");
                }
 
+               if (sshdr->asc == 0x29) {
+                       evt_type = SDEV_EVT_POWER_ON_RESET_OCCURRED;
+                       sdev_printk(KERN_WARNING, sdev,
+                                   "Power-on or device reset occurred\n");
+               }
+
                if (sshdr->asc == 0x2a && sshdr->ascq == 0x01) {
                        evt_type = SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED;
                        sdev_printk(KERN_WARNING, sdev,
index c72b97a74906249affa3a12828e83c8411d8c6cf..e5fcfa86704547cb1868159676850f3280467fff 100644 (file)
@@ -2743,6 +2743,9 @@ static void scsi_evt_emit(struct scsi_device *sdev, struct scsi_event *evt)
        case SDEV_EVT_ALUA_STATE_CHANGE_REPORTED:
                envp[idx++] = "SDEV_UA=ASYMMETRIC_ACCESS_STATE_CHANGED";
                break;
+       case SDEV_EVT_POWER_ON_RESET_OCCURRED:
+               envp[idx++] = "SDEV_UA=POWER_ON_RESET_OCCURRED";
+               break;
        default:
                /* do nothing */
                break;
@@ -2847,6 +2850,7 @@ struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
        case SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED:
        case SDEV_EVT_LUN_CHANGE_REPORTED:
        case SDEV_EVT_ALUA_STATE_CHANGE_REPORTED:
+       case SDEV_EVT_POWER_ON_RESET_OCCURRED:
        default:
                /* do nothing */
                break;
index 82e93ee94708c9f7de073b3e6c47826664525075..d68985c366b06df36193a81c5f98f338efce57e7 100644 (file)
@@ -64,9 +64,10 @@ enum scsi_device_event {
        SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED,        /* 2A 01  UA reported */
        SDEV_EVT_LUN_CHANGE_REPORTED,                   /* 3F 0E  UA reported */
        SDEV_EVT_ALUA_STATE_CHANGE_REPORTED,            /* 2A 06  UA reported */
+       SDEV_EVT_POWER_ON_RESET_OCCURRED,               /* 29 00  UA reported */
 
        SDEV_EVT_FIRST          = SDEV_EVT_MEDIA_CHANGE,
-       SDEV_EVT_LAST           = SDEV_EVT_ALUA_STATE_CHANGE_REPORTED,
+       SDEV_EVT_LAST           = SDEV_EVT_POWER_ON_RESET_OCCURRED,
 
        SDEV_EVT_MAXBITS        = SDEV_EVT_LAST + 1
 };