[PATCH 2/2] qla2xxx/tcm_qla2xxx: Remove qla_tgt_cmd->locked_rsp usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>

This patch drops legacy usage of qla_tgt_cmd->locked_rsp from
the main qla_target.c__qla_tgt_2*xx_xmit_response() code and
from qla_tgt_cmd proper.

It also converts tcm_qla2xxx to use tcm_qla2xxx_do_rsp() to provide
process context during an tcm_qla2xxx_handle_data() abort, and
drops the locked_rsp special case in tcm_qla2xxx_check_release_cmd()

Cc: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
---
 drivers/scsi/qla2xxx/qla_target.c               |   27 +++++++---------------
 drivers/scsi/qla2xxx/qla_target.h               |    1 -
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c |   25 ++++++++++++---------
 3 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index b512518..c71cb8c 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2010,15 +2010,13 @@ static int qla_tgt_pre_xmit_response(struct qla_tgt_cmd *cmd, struct qla_tgt_prm
 	struct se_cmd *se_cmd = &cmd->se_cmd;
 
 	if (unlikely(cmd->aborted)) {
-		int unlocked_term = (cmd->locked_rsp == 0);
-
 		ql_dbg(ql_dbg_tgt_mgt, vha, 0xe118, "qla_target(%d): terminating exchange "
 			"for aborted cmd=%p (se_cmd=%p, tag=%d)",
 			vha->vp_idx, cmd, se_cmd, cmd->tag);
 
 		cmd->state = QLA_TGT_STATE_ABORTED;
 
-		qla_tgt_send_term_exchange(vha, cmd, &cmd->atio, unlocked_term);
+		qla_tgt_send_term_exchange(vha, cmd, &cmd->atio, 0);
 
 		/* !! At this point cmd could be already freed !! */
 		return QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED;
@@ -2163,8 +2161,7 @@ static int __qla_tgt_2xxx_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
 		return res;
 	}
 
-	if (cmd->locked_rsp)
-		spin_lock_irqsave(&ha->hardware_lock, flags);
+	spin_lock_irqsave(&ha->hardware_lock, flags);
 
 	/* Does F/W have an IOCBs for this request */
 	res = qla_tgt_check_reserve_free_req(vha, full_req_cnt);
@@ -2223,16 +2220,14 @@ static int __qla_tgt_2xxx_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
 			" %p scsi_status: 0x%02x\n", pkt, scsi_status);
 
 	qla2x00_isp_cmd(vha, vha->req);
-	if (cmd->locked_rsp)
-		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
 	return 0;
 
 out_unmap_unlock:
 	if (cmd->sg_mapped)
 		qla_tgt_unmap_sg(vha, cmd);
-	if (cmd->locked_rsp)
-		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
 	return res;
 }
@@ -2417,8 +2412,7 @@ static int __qla_tgt_24xx_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
 		return res;
 	}
 
-	if (cmd->locked_rsp)
-		spin_lock_irqsave(&ha->hardware_lock, flags);
+	spin_lock_irqsave(&ha->hardware_lock, flags);
 
         /* Does F/W have an IOCBs for this request */
 	res = qla_tgt_check_reserve_free_req(vha, full_req_cnt);
@@ -2487,16 +2481,14 @@ static int __qla_tgt_24xx_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
 			" %p scsi_status: 0x%02x\n", pkt, scsi_status);
 
 	qla2x00_isp_cmd(vha, vha->req);
-	if (cmd->locked_rsp)
-		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
 	return 0;
 
 out_unmap_unlock:
 	if (cmd->sg_mapped)
 		qla_tgt_unmap_sg(vha, cmd);
-	if (cmd->locked_rsp)
-		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
 	return res;
 }
@@ -3029,7 +3021,7 @@ static int qla_tgt_2xxx_send_cmd(struct scsi_qla_host *vha, struct qla_tgt_cmd *
 {
 	atio_from_isp_t *atio = &cmd->atio;
 	uint32_t data_length;
-	int fcp_task_attr, data_dir, bidi = 0, ret;
+	int fcp_task_attr, data_dir, bidi = 0;
 	uint16_t lun;
 
 	/* make it be in network byte order */
@@ -3063,7 +3055,7 @@ static int qla_tgt_24xx_send_cmd(struct scsi_qla_host *vha, struct qla_tgt_cmd *
 {
 	atio_from_isp_t *atio = &cmd->atio;
 	uint32_t data_length;
-	int fcp_task_attr, data_dir, bidi = 0, ret;
+	int fcp_task_attr, data_dir, bidi = 0;
 
 	cmd->tag = atio->u.isp24.exchange_addr;
 	cmd->unpacked_lun = scsilun_to_int(
@@ -3134,7 +3126,6 @@ static int qla_tgt_handle_cmd_for_atio(struct scsi_qla_host *vha,
 
 	memcpy(&cmd->atio, atio, sizeof(*atio));
 	cmd->state = QLA_TGT_STATE_NEW;
-	cmd->locked_rsp = 1;
 	cmd->tgt = ha->qla_tgt;
 	cmd->vha = vha;
 
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index 3fcb912..92796bc 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -917,7 +917,6 @@ struct qla_tgt_sess {
 struct qla_tgt_cmd {
 	struct qla_tgt_sess *sess;
 	int state;
-	int locked_rsp;
 	atomic_t cmd_stop_free;
 	atomic_t cmd_free;
 	struct completion cmd_stop_free_comp;
diff --git a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
index a3e4ca3..cbe1320 100644
--- a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
+++ b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
@@ -478,13 +478,6 @@ int tcm_qla2xxx_check_release_cmd(struct se_cmd *se_cmd)
 
 	ha = sess->vha->hw;
 	/*
-	 * Check if qla_hw_data->hardware_lock is already held from an
-	 * exception path..  This also skips the possible wait for
-	 * completion on cmd_stop_free_comp below..
-	 */
-	if (!cmd->locked_rsp)
-		return target_put_sess_cmd(sess->se_sess, se_cmd);
-	/*
 	 * If the callback to tcm_qla2xxx_check_stop_free() has not finished,
 	 * before the release path is invoked, go ahead and wait on
 	 * cmd_stop_free_comp until tcm_qla2xxx_check_stop_free completes.
@@ -752,6 +745,16 @@ void tcm_qla2xxx_do_work(struct work_struct *work)
 	transport_handle_cdb_direct(se_cmd);
 }
 
+void tcm_qla2xxx_do_rsp(struct work_struct *work)
+{
+	struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
+	/*
+	 * Dispatch ->queue_status from workqueue process context
+	 */
+	transport_send_check_condition_and_sense(&cmd->se_cmd,
+				cmd->se_cmd.scsi_sense_reason, 0);
+}
+
 /*
  * Called from qla_target.c:qla_tgt_do_ctio_completion()
  */
@@ -776,10 +779,10 @@ int tcm_qla2xxx_handle_data(struct qla_tgt_cmd *cmd)
 		}
 		spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
 
-		cmd->locked_rsp = 0;		
-
-		return transport_send_check_condition_and_sense(&cmd->se_cmd,
-				TCM_CHECK_CONDITION_ABORT_CMD, 0);
+		se_cmd->scsi_sense_reason = TCM_CHECK_CONDITION_ABORT_CMD;
+		INIT_WORK(&cmd->work, tcm_qla2xxx_do_rsp);
+		queue_work(cmd->tgt->qla_tgt_wq, &cmd->work);
+		return 0;
 	}
 	/*
 	 * We now tell TCM to queue this WRITE CDB with TRANSPORT_PROCESS_WRITE
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux