Blame SOURCES/0098-scsi-scsi-qla2xxx-Complain-loudly-about-reference-co.patch

3c6e85
From cc9cd21f1c1e14fa5b2b3129f505447bc3be9283 Mon Sep 17 00:00:00 2001
3c6e85
From: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Date: Thu, 1 Aug 2019 15:55:58 -0400
3c6e85
Subject: [PATCH 098/124] [scsi] scsi: qla2xxx: Complain loudly about reference
3c6e85
 count underflow
3c6e85
3c6e85
Message-id: <20190801155618.12650-99-hmadhani@redhat.com>
3c6e85
Patchwork-id: 267873
3c6e85
O-Subject: [RHEL 7.8 e-stor PATCH 098/118] scsi: qla2xxx: Complain loudly about reference count underflow
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
A reference count underflow is a severe bug. Hence complain loudly if a
3c6e85
reference count underflow happens.
3c6e85
3c6e85
Cc: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
Cc: Giridhar Malavali <gmalavali@marvell.com>
3c6e85
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
3c6e85
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3c6e85
(cherry picked from commit db4bf822c58cd2b4a6718c982ce48a5292f5cc6a)
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3c6e85
---
3c6e85
 drivers/scsi/qla2xxx/qla_nvme.c | 15 +++++----------
3c6e85
 drivers/scsi/qla2xxx/qla_os.c   | 16 ++--------------
3c6e85
 2 files changed, 7 insertions(+), 24 deletions(-)
3c6e85
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
3c6e85
index 8ddd44bb6c7f..dea081c27182 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_nvme.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
3c6e85
@@ -131,11 +131,8 @@ static void qla_nvme_sp_ls_done(void *ptr, int res)
3c6e85
 	struct nvmefc_ls_req   *fd;
3c6e85
 	struct nvme_private *priv;
3c6e85
 
3c6e85
-	if (atomic_read(&sp->ref_count) == 0) {
3c6e85
-		ql_log(ql_log_warn, sp->fcport->vha, 0x2123,
3c6e85
-		    "SP reference-count to ZERO on LS_done -- sp=%p.\n", sp);
3c6e85
+	if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
3c6e85
 		return;
3c6e85
-	}
3c6e85
 
3c6e85
 	atomic_dec(&sp->ref_count);
3c6e85
 
3c6e85
@@ -160,6 +157,9 @@ static void qla_nvme_sp_done(void *ptr, int res)
3c6e85
 	nvme = &sp->u.iocb_cmd;
3c6e85
 	fd = nvme->u.nvme.desc;
3c6e85
 
3c6e85
+	if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
3c6e85
+		return;
3c6e85
+
3c6e85
 	atomic_dec(&sp->ref_count);
3c6e85
 
3c6e85
 	if (res == QLA_SUCCESS) {
3c6e85
@@ -199,13 +199,8 @@ static void qla_nvme_abort_work(struct work_struct *work)
3c6e85
 		return;
3c6e85
 	}
3c6e85
 
3c6e85
-	if (atomic_read(&sp->ref_count) == 0) {
3c6e85
-		WARN_ON(1);
3c6e85
-		ql_log(ql_log_info, fcport->vha, 0xffff,
3c6e85
-			"%s: command already aborted on sp: %p\n",
3c6e85
-			__func__, sp);
3c6e85
+	if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
3c6e85
 		return;
3c6e85
-	}
3c6e85
 
3c6e85
 	rval = ha->isp_ops->abort_command(sp);
3c6e85
 
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
index a32074dd4727..a3159a9a4c3e 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_os.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
@@ -762,14 +762,8 @@ qla2x00_sp_compl(void *ptr, int res)
3c6e85
 	struct scsi_cmnd *cmd = GET_CMD_SP(sp);
3c6e85
 	struct completion *comp = sp->comp;
3c6e85
 
3c6e85
-	if (atomic_read(&sp->ref_count) == 0) {
3c6e85
-		ql_dbg(ql_dbg_io, sp->vha, 0x3015,
3c6e85
-		    "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
3c6e85
-		    sp, GET_CMD_SP(sp));
3c6e85
-		if (ql2xextended_error_logging & ql_dbg_io)
3c6e85
-			WARN_ON(atomic_read(&sp->ref_count) == 0);
3c6e85
+	if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
3c6e85
 		return;
3c6e85
-	}
3c6e85
 
3c6e85
 	atomic_dec(&sp->ref_count);
3c6e85
 
3c6e85
@@ -872,14 +866,8 @@ qla2xxx_qpair_sp_compl(void *ptr, int res)
3c6e85
 	struct scsi_cmnd *cmd = GET_CMD_SP(sp);
3c6e85
 	struct completion *comp = sp->comp;
3c6e85
 
3c6e85
-	if (atomic_read(&sp->ref_count) == 0) {
3c6e85
-		ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079,
3c6e85
-		    "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
3c6e85
-		    sp, GET_CMD_SP(sp));
3c6e85
-		if (ql2xextended_error_logging & ql_dbg_io)
3c6e85
-			WARN_ON(atomic_read(&sp->ref_count) == 0);
3c6e85
+	if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
3c6e85
 		return;
3c6e85
-	}
3c6e85
 
3c6e85
 	atomic_dec(&sp->ref_count);
3c6e85
 
3c6e85
-- 
3c6e85
2.13.6
3c6e85