Commit 3dbec59b authored by Quinn Tran's avatar Quinn Tran Committed by Martin K. Petersen

scsi: qla2xxx: Prevent multiple active discovery commands per session

Add check to allow single discovery command per session to be sent
Signed-off-by: default avatarQuinn Tran <quinn.tran@cavium.com>
Signed-off-by: default avatarHimanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 6944dccb
...@@ -3127,16 +3127,16 @@ int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -3127,16 +3127,16 @@ int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
srb_t *sp; srb_t *sp;
if (!vha->flags.online) if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
goto done; return rval;
fcport->flags |= FCF_ASYNC_SENT;
fcport->disc_state = DSC_GID_PN; fcport->disc_state = DSC_GID_PN;
fcport->scan_state = QLA_FCPORT_SCAN; fcport->scan_state = QLA_FCPORT_SCAN;
sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC);
if (!sp) if (!sp)
goto done; goto done;
fcport->flags |= FCF_ASYNC_SENT;
sp->type = SRB_CT_PTHRU_CMD; sp->type = SRB_CT_PTHRU_CMD;
sp->name = "gidpn"; sp->name = "gidpn";
sp->gen1 = fcport->rscn_gen; sp->gen1 = fcport->rscn_gen;
...@@ -3177,8 +3177,8 @@ int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -3177,8 +3177,8 @@ int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport)
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done:
return rval; return rval;
} }
...@@ -3319,14 +3319,14 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -3319,14 +3319,14 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
srb_t *sp; srb_t *sp;
if (!vha->flags.online) if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
goto done; return rval;
fcport->flags |= FCF_ASYNC_SENT;
sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
if (!sp) if (!sp)
goto done; goto done;
fcport->flags |= FCF_ASYNC_SENT;
sp->type = SRB_CT_PTHRU_CMD; sp->type = SRB_CT_PTHRU_CMD;
sp->name = "gpsc"; sp->name = "gpsc";
sp->gen1 = fcport->rscn_gen; sp->gen1 = fcport->rscn_gen;
...@@ -3366,8 +3366,8 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -3366,8 +3366,8 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport)
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done:
return rval; return rval;
} }
...@@ -3780,7 +3780,7 @@ int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -3780,7 +3780,7 @@ int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
srb_t *sp; srb_t *sp;
if (!vha->flags.online) if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
return rval; return rval;
sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
...@@ -4337,15 +4337,15 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -4337,15 +4337,15 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
srb_t *sp; srb_t *sp;
if (!vha->flags.online) if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
goto done; return rval;
fcport->flags |= FCF_ASYNC_SENT;
fcport->disc_state = DSC_GNN_ID; fcport->disc_state = DSC_GNN_ID;
sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC);
if (!sp) if (!sp)
goto done; goto done;
fcport->flags |= FCF_ASYNC_SENT;
sp->type = SRB_CT_PTHRU_CMD; sp->type = SRB_CT_PTHRU_CMD;
sp->name = "gnnid"; sp->name = "gnnid";
sp->gen1 = fcport->rscn_gen; sp->gen1 = fcport->rscn_gen;
...@@ -4386,8 +4386,8 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -4386,8 +4386,8 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport)
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done:
return rval; return rval;
} }
...@@ -4474,15 +4474,15 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -4474,15 +4474,15 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *vha, fc_port_t *fcport)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
srb_t *sp; srb_t *sp;
if (!vha->flags.online) if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
goto done; return rval;
fcport->flags |= FCF_ASYNC_SENT;
fcport->disc_state = DSC_GFPN_ID; fcport->disc_state = DSC_GFPN_ID;
sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC);
if (!sp) if (!sp)
goto done; goto done;
fcport->flags |= FCF_ASYNC_SENT;
sp->type = SRB_CT_PTHRU_CMD; sp->type = SRB_CT_PTHRU_CMD;
sp->name = "gfpnid"; sp->name = "gfpnid";
sp->gen1 = fcport->rscn_gen; sp->gen1 = fcport->rscn_gen;
...@@ -4524,8 +4524,8 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -4524,8 +4524,8 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *vha, fc_port_t *fcport)
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done:
return rval; return rval;
} }
......
...@@ -207,7 +207,6 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -207,7 +207,6 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
lio->u.logio.flags |= SRB_LOGIN_RETRIED; lio->u.logio.flags |= SRB_LOGIN_RETRIED;
rval = qla2x00_start_sp(sp); rval = qla2x00_start_sp(sp);
if (rval != QLA_SUCCESS) { if (rval != QLA_SUCCESS) {
fcport->flags &= ~FCF_ASYNC_SENT;
fcport->flags |= FCF_LOGIN_NEEDED; fcport->flags |= FCF_LOGIN_NEEDED;
set_bit(RELOGIN_NEEDED, &vha->dpc_flags); set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
goto done_free_sp; goto done_free_sp;
...@@ -222,8 +221,8 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -222,8 +221,8 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done:
return rval; return rval;
} }
...@@ -245,9 +244,11 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -245,9 +244,11 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
{ {
srb_t *sp; srb_t *sp;
struct srb_iocb *lio; struct srb_iocb *lio;
int rval; int rval = QLA_FUNCTION_FAILED;
if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
return rval;
rval = QLA_FUNCTION_FAILED;
fcport->flags |= FCF_ASYNC_SENT; fcport->flags |= FCF_ASYNC_SENT;
sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
if (!sp) if (!sp)
...@@ -715,14 +716,13 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -715,14 +716,13 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
unsigned long flags; unsigned long flags;
u16 *mb; u16 *mb;
if (!vha->flags.online) if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
goto done; return rval;
ql_dbg(ql_dbg_disc, vha, 0x20d9, ql_dbg(ql_dbg_disc, vha, 0x20d9,
"Async-gnlist WWPN %8phC \n", fcport->port_name); "Async-gnlist WWPN %8phC \n", fcport->port_name);
spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
fcport->flags |= FCF_ASYNC_SENT;
fcport->disc_state = DSC_GNL; fcport->disc_state = DSC_GNL;
fcport->last_rscn_gen = fcport->rscn_gen; fcport->last_rscn_gen = fcport->rscn_gen;
fcport->last_login_gen = fcport->login_gen; fcport->last_login_gen = fcport->login_gen;
...@@ -730,8 +730,7 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -730,8 +730,7 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
list_add_tail(&fcport->gnl_entry, &vha->gnl.fcports); list_add_tail(&fcport->gnl_entry, &vha->gnl.fcports);
if (vha->gnl.sent) { if (vha->gnl.sent) {
spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
rval = QLA_SUCCESS; return QLA_SUCCESS;
goto done;
} }
vha->gnl.sent = 1; vha->gnl.sent = 1;
spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
...@@ -739,6 +738,8 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -739,6 +738,8 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
if (!sp) if (!sp)
goto done; goto done;
fcport->flags |= FCF_ASYNC_SENT;
sp->type = SRB_MB_IOCB; sp->type = SRB_MB_IOCB;
sp->name = "gnlist"; sp->name = "gnlist";
sp->gen1 = fcport->rscn_gen; sp->gen1 = fcport->rscn_gen;
...@@ -773,8 +774,8 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -773,8 +774,8 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done:
return rval; return rval;
} }
...@@ -898,7 +899,6 @@ qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -898,7 +899,6 @@ qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t *fcport)
rval = qla2x00_start_sp(sp); rval = qla2x00_start_sp(sp);
if (rval != QLA_SUCCESS) { if (rval != QLA_SUCCESS) {
fcport->flags &= ~FCF_ASYNC_SENT;
fcport->flags |= FCF_LOGIN_NEEDED; fcport->flags |= FCF_LOGIN_NEEDED;
set_bit(RELOGIN_NEEDED, &vha->dpc_flags); set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
goto done_free_sp; goto done_free_sp;
...@@ -940,16 +940,16 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) ...@@ -940,16 +940,16 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
struct port_database_24xx *pd; struct port_database_24xx *pd;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
if (!vha->flags.online) if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
goto done; return rval;
fcport->flags |= FCF_ASYNC_SENT;
fcport->disc_state = DSC_GPDB; fcport->disc_state = DSC_GPDB;
sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
if (!sp) if (!sp)
goto done; goto done;
fcport->flags |= FCF_ASYNC_SENT;
sp->type = SRB_MB_IOCB; sp->type = SRB_MB_IOCB;
sp->name = "gpdb"; sp->name = "gpdb";
sp->gen1 = fcport->rscn_gen; sp->gen1 = fcport->rscn_gen;
...@@ -995,8 +995,8 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) ...@@ -995,8 +995,8 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
dma_pool_free(ha->s_dma_pool, pd, pd_dma); dma_pool_free(ha->s_dma_pool, pd, pd_dma);
sp->free(sp); sp->free(sp);
done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done:
qla24xx_post_gpdb_work(vha, fcport, opt); qla24xx_post_gpdb_work(vha, fcport, opt);
return rval; return rval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment