Commit e2d817db authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi_dh_alua: simplify sense code handling

Most sense code is already handled in the generic
code, so we shouldn't be adding special cases here.
However, when doing so we need to check for
unit attention whenever we're sending an internal
command.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarEwan Milne <emilne@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent ad0ea64c
...@@ -85,7 +85,6 @@ struct alua_dh_data { ...@@ -85,7 +85,6 @@ struct alua_dh_data {
#define ALUA_POLICY_SWITCH_ALL 1 #define ALUA_POLICY_SWITCH_ALL 1
static char print_alua_state(int); static char print_alua_state(int);
static int alua_check_sense(struct scsi_device *, struct scsi_sense_hdr *);
static int realloc_buffer(struct alua_dh_data *h, unsigned len) static int realloc_buffer(struct alua_dh_data *h, unsigned len)
{ {
...@@ -189,8 +188,13 @@ static void stpg_endio(struct request *req, int error) ...@@ -189,8 +188,13 @@ static void stpg_endio(struct request *req, int error)
if (scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE, if (scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE,
&sense_hdr)) { &sense_hdr)) {
err = alua_check_sense(h->sdev, &sense_hdr); if (sense_hdr.sense_key == NOT_READY &&
if (err == ADD_TO_MLQUEUE) { sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a) {
/* ALUA state transition already in progress */
err = SCSI_DH_OK;
goto done;
}
if (sense_hdr.sense_key == UNIT_ATTENTION) {
err = SCSI_DH_RETRY; err = SCSI_DH_RETRY;
goto done; goto done;
} }
...@@ -399,28 +403,6 @@ static int alua_check_sense(struct scsi_device *sdev, ...@@ -399,28 +403,6 @@ static int alua_check_sense(struct scsi_device *sdev,
* LUN Not Accessible - ALUA state transition * LUN Not Accessible - ALUA state transition
*/ */
return ADD_TO_MLQUEUE; return ADD_TO_MLQUEUE;
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0b)
/*
* LUN Not Accessible -- Target port in standby state
*/
return SUCCESS;
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0c)
/*
* LUN Not Accessible -- Target port in unavailable state
*/
return SUCCESS;
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x12)
/*
* LUN Not Ready -- Offline
*/
return SUCCESS;
if (sdev->allow_restart &&
sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x02)
/*
* if the device is not started, we need to wake
* the error handler to start the motor
*/
return FAILED;
break; break;
case UNIT_ATTENTION: case UNIT_ATTENTION:
if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00) if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
...@@ -517,9 +499,16 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_ ...@@ -517,9 +499,16 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_
h->flags |= ALUA_RTPG_EXT_HDR_UNSUPP; h->flags |= ALUA_RTPG_EXT_HDR_UNSUPP;
goto retry; goto retry;
} }
/*
err = alua_check_sense(sdev, &sense_hdr); * Retry on ALUA state transition or if any
if (err == ADD_TO_MLQUEUE && time_before(jiffies, expiry)) { * UNIT ATTENTION occurred.
*/
if (sense_hdr.sense_key == NOT_READY &&
sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)
err = SCSI_DH_RETRY;
else if (sense_hdr.sense_key == UNIT_ATTENTION)
err = SCSI_DH_RETRY;
if (err == SCSI_DH_RETRY && time_before(jiffies, expiry)) {
sdev_printk(KERN_ERR, sdev, "%s: rtpg retry\n", sdev_printk(KERN_ERR, sdev, "%s: rtpg retry\n",
ALUA_DH_NAME); ALUA_DH_NAME);
scsi_print_sense_hdr(sdev, ALUA_DH_NAME, &sense_hdr); scsi_print_sense_hdr(sdev, ALUA_DH_NAME, &sense_hdr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment