Move the device online check from scsi_eh_flush_done_q to scsi_attempt_requeue_command so that it can be shared by other callers and simplifies scsi_eh_flush_done_q. To provide similar behavior also move the setting of a zero result value to scsi_eh_finish_cmd. Signed-off-by: Mike Christie <michaelc@xxxxxxxxxxx> Signed-off-by: Mike Anderson <andmike@xxxxxxxxxxxxxxxxxx> --- drivers/scsi/scsi_error.c | 26 ++++++-------------------- drivers/scsi/scsi_lib.c | 6 ++++++ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 417f119..c9b5598 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -835,6 +835,8 @@ void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q) { scmd->device->host->host_failed--; scmd->eh_eflags = 0; + if (!scmd->result) + scmd->result |= (DRIVER_TIMEOUT << 24); list_move_tail(&scmd->eh_entry, done_q); } EXPORT_SYMBOL(scsi_eh_finish_cmd); @@ -1555,26 +1557,10 @@ void scsi_eh_flush_done_q(struct list_head *done_q) list_for_each_entry_safe(scmd, next, done_q, eh_entry) { list_del_init(&scmd->eh_entry); - if (scsi_device_online(scmd->device)) { - SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush" - " retry cmd: %p\n", - current->comm, - scmd)); - scsi_attempt_requeue_command(scmd, - SCSI_MLQUEUE_DIS_RETRY); - } else { - /* - * If just we got sense for the device (called - * scsi_eh_get_sense), scmd->result is already - * set, do not set DRIVER_TIMEOUT. - */ - if (!scmd->result) - scmd->result |= (DRIVER_TIMEOUT << 24); - SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush finish" - " cmd: %p\n", - current->comm, scmd)); - scsi_finish_command(scmd); - } + SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush" + "attempt retry cmd: %p\n", + current->comm, scmd)); + scsi_attempt_requeue_command(scmd, SCSI_MLQUEUE_DIS_RETRY); } } EXPORT_SYMBOL(scsi_eh_flush_done_q); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3f01015..38c118f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -135,6 +135,12 @@ int scsi_attempt_requeue_command(struct scsi_cmnd *cmd, int reason) return 0; } + if (!scsi_device_online(cmd->device)) { + set_driver_byte(cmd, DRIVER_TIMEOUT); + scsi_finish_command(cmd); + return 0; + } + /* * Set the appropriate busy bit for the device/host. * -- 1.5.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html