Blame SOURCES/0096-scsi-scsi-qla2xxx-Split-the-__qla2x00_abort_all_cmds.patch

3c6e85
From 5889d7fc7bf72136f9229bffd5372b13056b108e Mon Sep 17 00:00:00 2001
3c6e85
From: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Date: Thu, 1 Aug 2019 15:55:56 -0400
3c6e85
Subject: [PATCH 096/124] [scsi] scsi: qla2xxx: Split the
3c6e85
 __qla2x00_abort_all_cmds() function
3c6e85
3c6e85
Message-id: <20190801155618.12650-97-hmadhani@redhat.com>
3c6e85
Patchwork-id: 267895
3c6e85
O-Subject: [RHEL 7.8 e-stor PATCH 096/118] scsi: qla2xxx: Split the __qla2x00_abort_all_cmds() function
3c6e85
Bugzilla: 1729270
3c6e85
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3c6e85
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3c6e85
3c6e85
From: Bart Van Assche <bvanassche@acm.org>
3c6e85
3c6e85
Bugzilla 1729270
3c6e85
3c6e85
Nesting in __qla2x00_abort_all_cmds() is way too deep. Reduce the nesting
3c6e85
level by introducing a helper function. This patch does not change any
3c6e85
functionality.
3c6e85
3c6e85
Reviewed-by: Laurence Oberman <loberman@redhat.com>
3c6e85
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
3c6e85
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
3c6e85
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3c6e85
(cherry picked from commit c4e521b654e15e372a6429e269e7e907b4698224)
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3c6e85
---
3c6e85
 drivers/scsi/qla2xxx/qla_os.c | 80 +++++++++++++++++++------------------------
3c6e85
 1 file changed, 36 insertions(+), 44 deletions(-)
3c6e85
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
index da093e59768b..a13798c4d178 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_os.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
@@ -1801,6 +1801,41 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
3c6e85
 	return QLA_SUCCESS;
3c6e85
 }
3c6e85
 
3c6e85
+static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
3c6e85
+			      unsigned long *flags)
3c6e85
+	__releases(qp->qp_lock_ptr)
3c6e85
+	__acquires(qp->qp_lock_ptr)
3c6e85
+{
3c6e85
+	scsi_qla_host_t *vha = qp->vha;
3c6e85
+	struct qla_hw_data *ha = vha->hw;
3c6e85
+
3c6e85
+	if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS) {
3c6e85
+		if (!sp_get(sp)) {
3c6e85
+			/* got sp */
3c6e85
+			spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
3c6e85
+			qla_nvme_abort(ha, sp, res);
3c6e85
+			spin_lock_irqsave(qp->qp_lock_ptr, *flags);
3c6e85
+		}
3c6e85
+	} else if (GET_CMD_SP(sp) && !ha->flags.eeh_busy &&
3c6e85
+		   !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
3c6e85
+		   !qla2x00_isp_reg_stat(ha) && sp->type == SRB_SCSI_CMD) {
3c6e85
+		/*
3c6e85
+		 * Don't abort commands in adapter during EEH recovery as it's
3c6e85
+		 * not accessible/responding.
3c6e85
+		 *
3c6e85
+		 * Get a reference to the sp and drop the lock. The reference
3c6e85
+		 * ensures this sp->done() call and not the call in
3c6e85
+		 * qla2xxx_eh_abort() ends the SCSI cmd (with result 'res').
3c6e85
+		 */
3c6e85
+		if (!sp_get(sp)) {
3c6e85
+			spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
3c6e85
+			qla2xxx_eh_abort(GET_CMD_SP(sp));
3c6e85
+			spin_lock_irqsave(qp->qp_lock_ptr, *flags);
3c6e85
+		}
3c6e85
+	}
3c6e85
+	sp->done(sp, res);
3c6e85
+}
3c6e85
+
3c6e85
 static void
3c6e85
 __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
3c6e85
 {
3c6e85
@@ -1823,50 +1858,7 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
3c6e85
 			req->outstanding_cmds[cnt] = NULL;
3c6e85
 			switch (sp->cmd_type) {
3c6e85
 			case TYPE_SRB:
3c6e85
-				if (sp->type == SRB_NVME_CMD ||
3c6e85
-				    sp->type == SRB_NVME_LS) {
3c6e85
-					if (!sp_get(sp)) {
3c6e85
-						/* got sp */
3c6e85
-						spin_unlock_irqrestore
3c6e85
-							(qp->qp_lock_ptr,
3c6e85
-							 flags);
3c6e85
-						qla_nvme_abort(ha, sp, res);
3c6e85
-						spin_lock_irqsave
3c6e85
-							(qp->qp_lock_ptr, flags);
3c6e85
-					}
3c6e85
-				} else if (GET_CMD_SP(sp) &&
3c6e85
-				    !ha->flags.eeh_busy &&
3c6e85
-				    (!test_bit(ABORT_ISP_ACTIVE,
3c6e85
-					&vha->dpc_flags)) &&
3c6e85
-				    !qla2x00_isp_reg_stat(ha) &&
3c6e85
-				    (sp->type == SRB_SCSI_CMD)) {
3c6e85
-					/*
3c6e85
-					 * Don't abort commands in adapter
3c6e85
-					 * during EEH recovery as it's not
3c6e85
-					 * accessible/responding.
3c6e85
-					 *
3c6e85
-					 * Get a reference to the sp and drop
3c6e85
-					 * the lock. The reference ensures this
3c6e85
-					 * sp->done() call and not the call in
3c6e85
-					 * qla2xxx_eh_abort() ends the SCSI cmd
3c6e85
-					 * (with result 'res').
3c6e85
-					 */
3c6e85
-					if (!sp_get(sp)) {
3c6e85
-						spin_unlock_irqrestore
3c6e85
-							(qp->qp_lock_ptr, flags);
3c6e85
-						qla2xxx_eh_abort(
3c6e85
-							GET_CMD_SP(sp));
3c6e85
-						spin_lock_irqsave
3c6e85
-							(qp->qp_lock_ptr, flags);
3c6e85
-						/*
3c6e85
-						 * Get rid of extra reference caused
3c6e85
-						 * by early exit from qla2xxx_eh_abort
3c6e85
-						 */
3c6e85
-						if (status == FAST_IO_FAIL)
3c6e85
-							atomic_dec(&sp->ref_count);
3c6e85
-					}
3c6e85
-				}
3c6e85
-				sp->done(sp, res);
3c6e85
+				qla2x00_abort_srb(qp, sp, res, &flags);
3c6e85
 				break;
3c6e85
 			case TYPE_TGT_CMD:
3c6e85
 				if (!vha->hw->tgt.tgt_ops || !tgt ||
3c6e85
-- 
3c6e85
2.13.6
3c6e85