qla2x00t-32gbit: Fix another race related to aborting commands

See also upstream commit 219d27d7147e ("scsi: qla2xxx: Fix race conditions
in the code for aborting SCSI commands").

----


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8338 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-05-04 03:11:59 +00:00
parent 6c9dddf26f
commit 0277a113c4
3 changed files with 22 additions and 64 deletions
-28
View File
@@ -595,34 +595,6 @@ static struct nvme_fc_port_template qla_nvme_fc_transport = {
.fcprqst_priv_sz = sizeof(struct nvme_private),
};
#define NVME_ABORT_POLLING_PERIOD 2
static int qla_nvme_wait_on_command(srb_t *sp)
{
int ret = QLA_SUCCESS;
wait_event_timeout(sp->nvme_ls_waitq, (atomic_read(&sp->ref_count) > 1),
NVME_ABORT_POLLING_PERIOD*HZ);
if (atomic_read(&sp->ref_count) > 1)
ret = QLA_FUNCTION_FAILED;
return ret;
}
void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp, int res)
{
int rval;
if (ha->flags.fw_started) {
rval = ha->isp_ops->abort_command(sp);
if (!rval && !qla_nvme_wait_on_command(sp))
ql_log(ql_log_warn, NULL, 0x2112,
"timed out waiting on sp=%p\n", sp);
} else {
sp->done(sp, res);
}
}
static void qla_nvme_unregister_remote_port(struct work_struct *work)
{
struct fc_port *fcport = container_of(work, struct fc_port,
-6
View File
@@ -144,7 +144,6 @@ struct pt_ls4_rx_unsol {
int qla_nvme_register_hba(struct scsi_qla_host *);
int qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *);
void qla_nvme_delete(struct scsi_qla_host *);
void qla_nvme_abort(struct qla_hw_data *, struct srb *sp, int res);
#else
static inline int qla_nvme_register_hba(struct scsi_qla_host *vha)
{
@@ -160,11 +159,6 @@ static inline int qla_nvme_register_remote(struct scsi_qla_host *vha,
static inline void qla_nvme_delete(struct scsi_qla_host *vha)
{
}
static inline void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp,
int res)
{
}
#endif
void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *,
+22 -30
View File
@@ -1776,42 +1776,34 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
__releases(qp->qp_lock_ptr)
__acquires(qp->qp_lock_ptr)
{
DECLARE_COMPLETION_ONSTACK(comp);
scsi_qla_host_t *vha = qp->vha;
struct qla_hw_data *ha = vha->hw;
int rval;
if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS) {
if (!sp_get(sp)) {
/* got sp */
spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
qla_nvme_abort(ha, sp, res);
spin_lock_irqsave(qp->qp_lock_ptr, *flags);
}
} else if (GET_CMD_SP(sp) && !ha->flags.eeh_busy &&
!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
!qla2x00_isp_reg_stat(ha) && sp->type == SRB_SCSI_CMD) {
/*
* Don't abort commands in adapter during EEH recovery as it's
* not accessible/responding.
*
* Get a reference to the sp and drop the lock. The reference
* ensures this sp->done() call and not the call in
* qla2xxx_eh_abort() ends the SCSI cmd (with result 'res').
*/
if (!sp_get(sp)) {
int status;
if (sp_get(sp))
return;
spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
status = qla2xxx_eh_abort(GET_CMD_SP(sp));
spin_lock_irqsave(qp->qp_lock_ptr, *flags);
/*
* Get rid of extra reference caused
* by early exit from qla2xxx_eh_abort
*/
if (status == FAST_IO_FAIL)
atomic_dec(&sp->ref_count);
if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS ||
(sp->type == SRB_SCSI_CMD && !ha->flags.eeh_busy &&
!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
!qla2x00_isp_reg_stat(ha))) {
sp->comp = ∁
rval = ha->isp_ops->abort_command(sp);
spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
switch (rval) {
case QLA_SUCCESS:
sp->done(sp, res);
break;
case QLA_FUNCTION_PARAMETER_ERROR:
wait_for_completion(&comp);
break;
}
spin_lock_irqsave(qp->qp_lock_ptr, *flags);
sp->comp = NULL;
}
sp->done(sp, res);
}
static void