• Brian King's avatar
    scsi: ipr: Fix SATA EH hang · ef97d8ae
    Brian King authored
    This patch fixes a hang that can occur in ATA EH with ipr. With ipr's
    usage of libata, commands should never end up on ap->eh_done_q. The
    timeout function we use for ipr, even for SATA devices, is
    scsi_times_out, so ATA_QCFLAG_EH_SCHEDULED never gets set for ipr and EH
    is driven completely by ipr and SCSI. The SCSI EH thread ends up calling
    ipr's eh_device_reset_handler, which then calls
    ata_std_error_handler. This ends up calling ipr_sata_reset, which issues
    a reset to the device. This should result in all pending commands
    getting failed back and having ata_qc_complete called for them, which
    should end up clearing ATA_QCFLAG_FAILED as qc->flags gets zeroed in
    ata_qc_free.  This ensures that when we end up in ata_eh_finish, we
    don't do anything more with the command.
    
    On adapters that only support a single interrupt and when running with
    two MSI-X vectors or less, the adapter firmware guarantees that
    responses to all outstanding commands are sent back prior to sending the
    response to the SATA reset command.  On newer adapters supporting
    multiple HRRQs, however, this can no longer be guaranteed, since the
    command responses and reset response may be processed on different
    HRRQs.
    
    If ipr returns from ipr_sata_reset before the outstanding command was
    returned, this sends us down the path of __ata_eh_qc_complete which then
    moves the associated scsi_cmd from the work_q in
    scsi_eh_bus_device_reset to ap->eh_done_q, which then will sit there
    forever and we will be wedged.
    
    This patch fixes this up by ensuring that any outstanding commands are
    flushed before returning from eh_device_reset_handler for a SATA device.
    Reported-by: default avatarDavid Jeffery <djeffery@redhat.com>
    Signed-off-by: default avatarBrian King <brking@linux.vnet.ibm.com>
    Reviewed-by: default avatarWendy Xiong <wenxiong@linux.vnet.ibm.com>
    Tested-by: default avatarWendy Xiong <wenxiong@linux.vnet.ibm.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    ef97d8ae
ipr.c 301 KB