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