Implement new EH scheduling from timeout. ata_scsi_timedout() also takes care of the race condition in which scsi_eh_schedule_qc() sets ATA_QCFLAG_EH_SCHEDULED but fails to acutally schedule EH for the qc because it loses to timeout. A timeout is HSM violation condition. New EH assumes that on a timeout the state of the controller and devices are unknown and dangerous. So, all active commands are aborted and the port is frozen. Note that commands which get aborted this way don't have its qc->err_mask set and its retries count will be compensated. Signed-off-by: Tejun Heo <htejun@xxxxxxxxx> --- drivers/scsi/libata-eh.c | 33 ++++++++++++++++++++++++++++----- 1 files changed, 28 insertions(+), 5 deletions(-) 0f79b4bddad85f3b2a55a46f316721b5492fd8ba diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c index e731c04..97ec527 100644 --- a/drivers/scsi/libata-eh.c +++ b/drivers/scsi/libata-eh.c @@ -66,19 +66,42 @@ enum scsi_eh_timer_return ata_scsi_timed struct Scsi_Host *host = cmd->device->host; struct ata_port *ap = (struct ata_port *) &host->hostdata[0]; unsigned long flags; + int i; struct ata_queued_cmd *qc; enum scsi_eh_timer_return ret = EH_HANDLED; DPRINTK("ENTER\n"); spin_lock_irqsave(&ap->host_set->lock, flags); - qc = ata_qc_from_tag(ap, ap->active_tag); - if (qc) { - WARN_ON(qc->scsicmd != cmd); - qc->flags |= ATA_QCFLAG_EH_SCHEDULED; - qc->err_mask |= AC_ERR_TIMEOUT; + + for (i = 0; i < ATA_MAX_QUEUE; i++) { + /* If ata_eh_scheduled_qc() raced with us and lost, + * EH_SCHEDULED flag would already be set, so we + * cannot use ata_qc_from_tag() here. + */ + qc = __ata_qc_from_tag(ap, i); + if (qc && qc->flags & ATA_QCFLAG_ACTIVE && qc->scsicmd == cmd) + break; + } + + if (i < ATA_MAX_QUEUE) { + /* qc->err_mask belongs to the command owner, so it + * cannot be altered here. Use ATA_QCFLAG_TIMEOUT + * instead. EH is responsible for merging this flag + * into err_mask after claiming qc ownership. + */ + qc->flags |= ATA_QCFLAG_TIMEOUT | ATA_QCFLAG_EH_SCHEDULED; + qc->dev->flags |= ATA_DFLAG_FAILED; + + if (ap->ops->error_handler) + ata_eh_schedule_port(ap, ATA_EH_FREEZE); + else + /* old EH, do what it used to do */ + qc->err_mask |= AC_ERR_TIMEOUT; + ret = EH_NOT_HANDLED; } + spin_unlock_irqrestore(&ap->host_set->lock, flags); DPRINTK("EXIT, ret=%d\n", ret); -- 1.2.4 - : send the line "unsubscribe linux-ide" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html