--- linux/drivers/scsi/scsi_error.c 2004-10-23 14:10:13.000000000 +1000 +++ linux/drivers/scsi/scsi_error.c2610rc1ds 2004-11-08 16:43:52.000000000 +1000 @@ -268,16 +268,42 @@ * * Return value: * SUCCESS or FAILED or NEEDS_RETRY + * + * Notes: + * When a deferred error is detected the current command has + * not been executed and needs retrying. **/ static int scsi_check_sense(struct scsi_cmnd *scmd) { - if (!SCSI_SENSE_VALID(scmd)) - return FAILED; + struct scsi_sense_hdr sshdr; - if (scmd->sense_buffer[2] & 0xe0) - return SUCCESS; + if (! scsi_command_normalize_sense(scmd, &sshdr)) + return FAILED; /* no valid sense data */ - switch (scmd->sense_buffer[2] & 0xf) { + if (scsi_sense_is_deferred(&sshdr)) + return NEEDS_RETRY; + + /* + * Previous logic looked for FILEMARK, EOM or ILI which are + * mainly associated with tapes and returned SUCCESS. + */ + if (sshdr.response_code == 0x70) { + /* fixed format */ + if (scmd->sense_buffer[2] & 0xe0) + return SUCCESS; + } else { + /* + * descriptor format: look for "stream commands sense data + * descriptor" (see SSC-3). Assume single sense data + * descriptor. Ignore ILI from SBC-2 READ LONG and WRITE LONG. + */ + if ((sshdr.additional_length > 3) && + (scmd->sense_buffer[8] == 0x4) && + (scmd->sense_buffer[11] & 0xe0)) + return SUCCESS; + } + + switch (sshdr.sense_key) { case NO_SENSE: return SUCCESS; case RECOVERED_ERROR: @@ -301,19 +327,15 @@ * if the device is in the process of becoming ready, we * should retry. */ - if ((scmd->sense_buffer[12] == 0x04) && - (scmd->sense_buffer[13] == 0x01)) { + if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01)) return NEEDS_RETRY; - } /* * if the device is not started, we need to wake * the error handler to start the motor */ if (scmd->device->allow_restart && - (scmd->sense_buffer[12] == 0x04) && - (scmd->sense_buffer[13] == 0x02)) { + (sshdr.asc == 0x04) && (sshdr.ascq == 0x02)) return FAILED; - } return SUCCESS; /* these three are not supported */ @@ -1358,7 +1380,8 @@ return SUCCESS; case RESERVATION_CONFLICT: - printk("scsi%d (%d,%d,%d) : reservation conflict\n", + printk(KERN_INFO "scsi: reservation conflict: host" + " %d channel %d id %d lun %d\n", scmd->device->host->host_no, scmd->device->channel, scmd->device->id, scmd->device->lun); return SUCCESS; /* causes immediate i/o error */