Skip to content

Commit

Permalink
scsi: qla2xxx: Complain loudly about reference count underflow
Browse files Browse the repository at this point in the history
A reference count underflow is a severe bug. Hence complain loudly if a
reference count underflow happens.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Bart Van Assche authored and Martin K. Petersen committed Apr 29, 2019
1 parent d4556a4 commit db4bf82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
15 changes: 5 additions & 10 deletions drivers/scsi/qla2xxx/qla_nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
16 changes: 2 additions & 14 deletions drivers/scsi/qla2xxx/qla_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,14 +716,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);

Expand Down Expand Up @@ -827,14 +821,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);

Expand Down

0 comments on commit db4bf82

Please sign in to comment.