scsi: qla2xxx: Remove session creation redundant code

Current code creates a session when a new port is
discovered, and a PLOGI/PRLI is received. There is
no need to create session when command has arrived.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Quinn Tran 2017-12-28 12:33:32 -08:00 committed by Martin K. Petersen
parent e374f9f592
commit fb35265b12

View file

@ -2018,15 +2018,10 @@ static void qlt_24xx_handle_abts(struct scsi_qla_host *vha,
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf012,
"qla_target(%d): task abort for non-existant session\n",
vha->vp_idx);
rc = qlt_sched_sess_work(vha->vha_tgt.qla_tgt,
QLA_TGT_SESS_WORK_ABORT, abts, sizeof(*abts));
spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
if (rc != 0) {
qlt_24xx_send_abts_resp(ha->base_qpair, abts,
FCP_TMF_REJECTED, false);
}
qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_REJECTED,
false);
return;
}
spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
@ -4246,87 +4241,6 @@ static struct qla_tgt_cmd *qlt_get_tag(scsi_qla_host_t *vha,
return cmd;
}
static void qlt_create_sess_from_atio(struct work_struct *work)
{
struct qla_tgt_sess_op *op = container_of(work,
struct qla_tgt_sess_op, work);
scsi_qla_host_t *vha = op->vha;
struct qla_hw_data *ha = vha->hw;
struct fc_port *sess;
struct qla_tgt_cmd *cmd;
unsigned long flags;
uint8_t *s_id = op->atio.u.isp24.fcp_hdr.s_id;
spin_lock_irqsave(&vha->cmd_list_lock, flags);
list_del(&op->cmd_list);
spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
if (op->aborted) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf083,
"sess_op with tag %u is aborted\n",
op->atio.u.isp24.exchange_addr);
goto out_term;
}
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf022,
"qla_target(%d): Unable to find wwn login"
" (s_id %x:%x:%x), trying to create it manually\n",
vha->vp_idx, s_id[0], s_id[1], s_id[2]);
if (op->atio.u.raw.entry_count > 1) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf023,
"Dropping multy entry atio %p\n", &op->atio);
goto out_busy;
}
sess = qlt_make_local_sess(vha, s_id);
/* sess has an extra creation ref. */
if (!sess)
goto out_busy;
/*
* Now obtain a pre-allocated session tag using the original op->atio
* packet header, and dispatch into __qlt_do_work() using the existing
* process context.
*/
cmd = qlt_get_tag(vha, sess, &op->atio);
if (!cmd) {
struct qla_qpair *qpair = ha->base_qpair;
spin_lock_irqsave(qpair->qp_lock_ptr, flags);
qlt_send_busy(qpair, &op->atio, tc_sam_status);
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
spin_lock_irqsave(&ha->tgt.sess_lock, flags);
ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
kfree(op);
return;
}
/*
* __qlt_do_work() will call qlt_put_sess() to release
* the extra reference taken above by qlt_make_local_sess()
*/
__qlt_do_work(cmd);
kfree(op);
return;
out_term:
qlt_send_term_exchange(vha->hw->base_qpair, NULL, &op->atio, 0, 0);
kfree(op);
return;
out_busy:
{
struct qla_qpair *qpair = ha->base_qpair;
spin_lock_irqsave(qpair->qp_lock_ptr, flags);
qlt_send_busy(qpair, &op->atio, qla_sam_status);
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
kfree(op);
}
return;
}
/* ha->hardware_lock supposed to be held on entry */
static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha,
struct atio_from_isp *atio)
@ -4351,23 +4265,8 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha,
return -EBUSY;
sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, atio->u.isp24.fcp_hdr.s_id);
if (unlikely(!sess)) {
struct qla_tgt_sess_op *op = kzalloc(sizeof(struct qla_tgt_sess_op),
GFP_ATOMIC);
if (!op)
return -ENOMEM;
memcpy(&op->atio, atio, sizeof(*atio));
op->vha = vha;
spin_lock_irqsave(&vha->cmd_list_lock, flags);
list_add_tail(&op->cmd_list, &vha->qla_sess_op_cmd_list);
spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
INIT_WORK(&op->work, qlt_create_sess_from_atio);
queue_work(qla_tgt_wq, &op->work);
return 0;
}
if (unlikely(!sess))
return -EFAULT;
/* Another WWN used to have our s_id. Our PLOGI scheduled its
* session deletion, but it's still in sess_del_work wq */
@ -4477,14 +4376,11 @@ static int qlt_handle_task_mgmt(struct scsi_qla_host *vha, void *iocb)
{
struct atio_from_isp *a = (struct atio_from_isp *)iocb;
struct qla_hw_data *ha = vha->hw;
struct qla_tgt *tgt;
struct fc_port *sess;
u64 unpacked_lun;
int fn;
unsigned long flags;
tgt = vha->vha_tgt.qla_tgt;
fn = a->u.isp24.fcp_cmnd.task_mgmt_flags;
spin_lock_irqsave(&ha->tgt.sess_lock, flags);
@ -4495,15 +4391,7 @@ static int qlt_handle_task_mgmt(struct scsi_qla_host *vha, void *iocb)
unpacked_lun =
scsilun_to_int((struct scsi_lun *)&a->u.isp24.fcp_cmnd.lun);
if (!sess) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf024,
"qla_target(%d): task mgmt fn 0x%x for "
"non-existant session\n", vha->vp_idx, fn);
return qlt_sched_sess_work(tgt, QLA_TGT_SESS_WORK_TM, iocb,
sizeof(struct atio_from_isp));
}
if (sess->deleted)
if (sess == NULL || sess->deleted)
return -EFAULT;
return qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);