scsi: qla2xxx: Fix extraneous ref on sp's after adapter break
authorBill Kuzeja <William.Kuzeja@stratus.com>
Thu, 25 May 2017 19:26:31 +0000 (15:26 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 1 Jun 2017 02:49:06 +0000 (22:49 -0400)
Hung task timeouts can result if a qlogic board breaks unexpectedly
while running I/O. These tasks become hung because command srb reference
counts are not going to zero, hence the affected srbs and commands do
not get freed. This fix accounts for this extra reference in the srbs in
the case of a board failure.

Fixes: a465537ad1a4 ("qla2xxx: Disable the adapter and skip error recovery in case of register disconnect")
Signed-off-by: Bill Kuzeja <william.kuzeja@stratus.com>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_os.c

index 2a2ce7476339ec56cca066b48300a340fa5ed134..79f050256c55c735c612c4553124ccf9e80fda0c 100644 (file)
@@ -1640,7 +1640,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
 void
 qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
 {
-       int que, cnt;
+       int que, cnt, status;
        unsigned long flags;
        srb_t *sp;
        struct qla_hw_data *ha = vha->hw;
@@ -1670,8 +1670,12 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
                                         */
                                        sp_get(sp);
                                        spin_unlock_irqrestore(&ha->hardware_lock, flags);
-                                       qla2xxx_eh_abort(GET_CMD_SP(sp));
+                                       status = qla2xxx_eh_abort(GET_CMD_SP(sp));
                                        spin_lock_irqsave(&ha->hardware_lock, flags);
+                                       /* Get rid of extra reference if immediate exit
+                                        * from ql2xxx_eh_abort */
+                                       if (status == FAILED && (qla2x00_isp_reg_stat(ha)))
+                                               atomic_dec(&sp->ref_count);
                                }
                                req->outstanding_cmds[cnt] = NULL;
                                sp->done(sp, res);