All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@cavium.com>
To: James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com
Cc: himanshu.madhani@cavium.com, linux-scsi@vger.kernel.org
Subject: [PATCH 28/43] qla2xxx: Remove session creation redundant code
Date: Tue, 19 Dec 2017 22:56:29 -0800	[thread overview]
Message-ID: <20171220065644.21511-29-himanshu.madhani@cavium.com> (raw)
In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com>

From: Quinn Tran <quinn.tran@cavium.com>

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>
---
 drivers/scsi/qla2xxx/qla_target.c | 122 ++------------------------------------
 1 file changed, 5 insertions(+), 117 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 93910e56643d..598ec3481a8c 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2016,15 +2016,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);
@@ -4265,87 +4260,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)
@@ -4370,23 +4284,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 */
@@ -4496,14 +4395,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);
@@ -4514,15 +4410,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);
-- 
2.12.0

  parent reply	other threads:[~2017-12-20  6:57 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20  6:56 [PATCH 00/43] qla2xxx: Driver update Himanshu Madhani
2017-12-20  6:56 ` [PATCH 01/43] qla2xxx: Fix stale memory access for name pointer Himanshu Madhani
2017-12-20 16:25   ` Bart Van Assche
2017-12-20 20:37     ` Madhani, Himanshu
2017-12-21  5:26   ` kbuild test robot
2017-12-21  5:26   ` [RFC PATCH] qla2xxx: sp_str[] can be static kbuild test robot
2017-12-20  6:56 ` [PATCH 02/43] qla2xxx: Fix NULL pointer access for fcport structure Himanshu Madhani
2017-12-20 16:26   ` Bart Van Assche
2017-12-20 20:38     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 03/43] qla2xxx: Use IOCB path to submit Control VP MBX command Himanshu Madhani
2017-12-20 16:29   ` Bart Van Assche
2017-12-20 20:39     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 04/43] qla2xxx: Use chip reset to bring down laser on unload Himanshu Madhani
2017-12-20  6:56 ` [PATCH 05/43] qla2xxx: Add boundary checks for exchanges to be offloaded Himanshu Madhani
2017-12-20  6:56 ` [PATCH 06/43] qla2xxx: Fix stale mem access for IRQ name Himanshu Madhani
2017-12-20 16:39   ` Bart Van Assche
2017-12-20 20:41     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 07/43] qla2xxx: Add ability to track IOCB resource for FW Himanshu Madhani
2017-12-20 16:51   ` Bart Van Assche
2017-12-20 20:57     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 08/43] qla2xxx: Chip reset uses wrong lock during IO flush Himanshu Madhani
2017-12-20  6:56 ` [PATCH 09/43] qla2xxx: Fix Firmware dump size for Extended login and Exchange Offload Himanshu Madhani
2017-12-20  6:56 ` [PATCH 10/43] qla2xxx: Replace GPDB with async ADISC command Himanshu Madhani
2017-12-20  6:56 ` [PATCH 11/43] qla2xxx: Move work element processing out of DPC thread Himanshu Madhani
2017-12-20  6:56 ` [PATCH 12/43] qla2xxx: Enable ATIO interrupt handshake for ISP27XX Himanshu Madhani
2017-12-20  6:56 ` [PATCH 13/43] qla2xxx: Use shadow register " Himanshu Madhani
2017-12-20  6:56 ` [PATCH 14/43] qla2xxx: Add option for use reserve exch for ELS Himanshu Madhani
2017-12-20 16:53   ` Bart Van Assche
2017-12-20 21:40     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 15/43] qla2xxx: Add ability to send PRLO Himanshu Madhani
2017-12-20  6:56 ` [PATCH 16/43] qla2xxx: Don't call dma_free_coherent with IRQ disabled Himanshu Madhani
2017-12-20  6:56 ` [PATCH 17/43] qla2xxx: Allow target mode to accept PRLI in dual mode Himanshu Madhani
2017-12-20  6:56 ` [PATCH 18/43] qla2xxx: Tweak resource count dump Himanshu Madhani
2017-12-20  6:56 ` [PATCH 19/43] qla2xxx: Fix session cleanup for N2N Himanshu Madhani
2017-12-21  6:01   ` kbuild test robot
2017-12-20  6:56 ` [PATCH 20/43] qla2xxx: Use known NPort ID for Management Server login Himanshu Madhani
2017-12-20  6:56 ` [PATCH 21/43] qla2xxx: Remove calling cancel_work_sync() Himanshu Madhani
2017-12-20 16:56   ` Bart Van Assche
2017-12-20 21:41     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 22/43] qla2xxx: Add switch command to simplify fabric discovery Himanshu Madhani
2017-12-20 18:09   ` Ewan D. Milne
2017-12-21  0:04     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 23/43] qla2xxx: Add lock protection around host lookup Himanshu Madhani
2017-12-20  6:56 ` [PATCH 24/43] qla2xxx: Reduce the use of terminate exchange Himanshu Madhani
2017-12-20  6:56 ` [PATCH 25/43] qla2xxx: Reduce trace noise for Async Events Himanshu Madhani
2017-12-20  6:56 ` [PATCH 26/43] qla2xxx: Fix login state machine freeze Himanshu Madhani
2017-12-20  6:56 ` [PATCH 27/43] qla2xxx: Migrate switch registration commands away from mailbox interface Himanshu Madhani
2017-12-20  6:56 ` Himanshu Madhani [this message]
2017-12-20  6:56 ` [PATCH 29/43] qla2xxx: Fix GPNFT/GNNFT error handling Himanshu Madhani
2017-12-20  6:56 ` [PATCH 30/43] qla2xxx: Properly extract ADISC error codes Himanshu Madhani
2017-12-20  6:56 ` [PATCH 31/43] qla2xxx: Add ability to use GPNFT/GNNFT for RSCN handling Himanshu Madhani
2017-12-20  6:56 ` [PATCH 32/43] qla2xxx: Allow relogin and session creation after reset Himanshu Madhani
2017-12-20  6:56 ` [PATCH 33/43] qla2xxx: Increase verbosity of debug messages logged Himanshu Madhani
2017-12-20  6:56 ` [PATCH 34/43] qla2xxx: Delay loop id allocation at login Himanshu Madhani
2017-12-20  6:56 ` [PATCH 35/43] qla2xxx: Add retry limit for fabric scan logic Himanshu Madhani
2017-12-20  6:56 ` [PATCH 36/43] qla2xxx: Add counters for Exchange Buffer to debugfs Himanshu Madhani
2017-12-20  6:56 ` [PATCH 37/43] qla2xxx: Prevent multiple active discovery commands per session Himanshu Madhani
2017-12-20  6:56 ` [PATCH 38/43] qla2xxx: Prevent relogin trigger from sending too many commands Himanshu Madhani
2017-12-20  6:56 ` [PATCH 39/43] qla2xxx: Check FCF_ASYNC_SENT flag Himanshu Madhani
2017-12-20  6:56 ` [PATCH 40/43] qla2xxx: Remove unused argument from qlt_schedule_sess_for_deletion() Himanshu Madhani
2017-12-20  6:56 ` [PATCH 41/43] qla2xxx: Serialize session deletion by using work_lock Himanshu Madhani
2017-12-20  6:56 ` [PATCH 42/43] qla2xxx: Serialize session free in qlt_free_session_done Himanshu Madhani
2017-12-20  6:56 ` [PATCH 43/43] qla2xxx: Update driver version to 10.00.00.04-k Himanshu Madhani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171220065644.21511-29-himanshu.madhani@cavium.com \
    --to=himanshu.madhani@cavium.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.