[PATCH 2/2] tcm_qla2xxx: Drop legacy qla_tgt_cmd->cmd_stop_free_comp usage

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

 



From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>

This patch converts tcm_qla2xxx to use target_put_sess_cmd() for
signal descriptor release.  It also converts legacy access of struct
ala_hw_data->hardware_lock n TFO->check_stop_free() and
TFO->check_release_cmd() callers to use a single target_put_sess_cmd
in tcm_qla2xxx_check_stop_free().

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

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 963bd45..ddcb70b 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -3151,7 +3151,6 @@ static int qla_tgt_handle_cmd_for_atio(struct scsi_qla_host *vha,
 	}
 
 	INIT_LIST_HEAD(&cmd->cmd_list);
-	init_completion(&cmd->cmd_stop_free_comp);
 
 	memcpy(&cmd->atio, atio, sizeof(*atio));
 	cmd->state = QLA_TGT_STATE_NEW;
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index 95efe44..e868490 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -917,9 +917,6 @@ struct qla_tgt_sess {
 struct qla_tgt_cmd {
 	struct qla_tgt_sess *sess;
 	int state;
-	atomic_t cmd_stop_free;
-	atomic_t cmd_free;
-	struct completion cmd_stop_free_comp;
 	struct se_cmd se_cmd;
 	struct work_struct free_work;
 	struct work_struct work;
diff --git a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c
index bf06deb..02910d6 100644
--- a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c
+++ b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c
@@ -1051,7 +1051,6 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
 	.tpg_get_inst_index		= tcm_qla2xxx_tpg_get_inst_index,
 	.new_cmd_map			= NULL,
 	.check_stop_free		= tcm_qla2xxx_check_stop_free,
-	.check_release_cmd		= tcm_qla2xxx_check_release_cmd,
 	.release_cmd			= tcm_qla2xxx_release_cmd,
 	.shutdown_session		= tcm_qla2xxx_shutdown_session,
 	.close_session			= tcm_qla2xxx_close_session,
diff --git a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
index 49b3e69..8fe8710 100644
--- a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
+++ b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
@@ -406,20 +406,13 @@ void tcm_qla2xxx_free_cmd(struct qla_tgt_cmd *cmd)
 	 * a call to transport_generic_free_cmd_intr() is not possible..
 	 */
 	if (!cmd->se_cmd.se_dev) {
-		atomic_set(&cmd->cmd_stop_free, 1);
-		atomic_set(&cmd->cmd_free, 1);
-		smp_mb__after_atomic_dec();
+		target_put_sess_cmd(cmd->se_cmd.se_sess, &cmd->se_cmd);	
 		transport_generic_free_cmd(&cmd->se_cmd, 0);
 		return;
 	}
 
-	if (!atomic_read(&cmd->se_cmd.t_transport_complete)) {
-		atomic_set(&cmd->cmd_stop_free, 1);
-		smp_mb__after_atomic_dec();
-	}
-
-	atomic_set(&cmd->cmd_free, 1);
-	smp_mb__after_atomic_dec();
+	if (!atomic_read(&cmd->se_cmd.t_transport_complete))
+		target_put_sess_cmd(cmd->se_cmd.se_sess, &cmd->se_cmd);
 
 	INIT_WORK(&cmd->work, tcm_qla2xxx_complete_free);
 	queue_work(tcm_qla2xxx_free_wq, &cmd->work);
@@ -430,13 +423,9 @@ void tcm_qla2xxx_free_cmd(struct qla_tgt_cmd *cmd)
  */
 int tcm_qla2xxx_check_stop_free(struct se_cmd *se_cmd)
 {
-	struct qla_tgt_cmd *cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd);
-	struct qla_tgt_mgmt_cmd *mcmd;
-	struct qla_hw_data *ha;
-	unsigned long flags;
-
 	if (se_cmd->se_tmr_req) {
-		mcmd = container_of(se_cmd, struct qla_tgt_mgmt_cmd, se_cmd);
+		struct qla_tgt_mgmt_cmd *mcmd = container_of(se_cmd,
+				struct qla_tgt_mgmt_cmd, se_cmd);
 		/*
 		 * Release the associated se_cmd->se_tmr_req and se_cmd
 		 * TMR related state now.
@@ -445,55 +434,7 @@ int tcm_qla2xxx_check_stop_free(struct se_cmd *se_cmd)
 		qla_tgt_free_mcmd(mcmd);
 		return 1;
 	}
-	ha = cmd->sess->vha->hw;
-	/*
- 	 * Set cmd_stop_free and wakeup cmd_stop_free_comp if necessary
- 	 * if tcm_qla2xxx_release_cmd() context is waiting for completion.
- 	 */
-	spin_lock_irqsave(&ha->hardware_lock, flags);
-	atomic_set(&cmd->cmd_stop_free, 1);
-	if (atomic_read(&cmd->cmd_free) != 0)
-		complete(&cmd->cmd_stop_free_comp);
-	spin_unlock_irqrestore(&ha->hardware_lock, flags);
-
-	return 0;
-}
-
-int tcm_qla2xxx_check_release_cmd(struct se_cmd *se_cmd)
-{
-	struct qla_tgt_cmd *cmd;
-	struct qla_tgt_sess *sess;
-	struct qla_hw_data *ha;
-	unsigned long flags;
-	int ret = 0;
-
-	if (se_cmd->se_tmr_req != NULL)
-		return 0;
-
-	cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd);
-	sess = cmd->sess;
-
-	if (!sess)
-		BUG();
-
-	ha = sess->vha->hw;
-	/*
-	 * 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.
-	 */
-	spin_lock_irqsave(&ha->hardware_lock, flags);
-	if (atomic_read(&cmd->cmd_stop_free) != 1) {
-		pr_warn("Detected cmd->cmd_stop_free != 0, waiting on"
-			" cmd_stop_free_comp for cmd: %p\n", cmd);
-		spin_unlock_irqrestore(&ha->hardware_lock, flags);
-		wait_for_completion(&cmd->cmd_stop_free_comp);
-		spin_lock_irqsave(&ha->hardware_lock, flags);
-	}
-	ret = target_put_sess_cmd(sess->se_sess, se_cmd);
-	spin_unlock_irqrestore(&ha->hardware_lock, flags);
-
-	return ret;
+	return target_put_sess_cmd(se_cmd->se_sess, se_cmd);
 }
 
 /* tcm_qla2xxx_release_cmd - Callback from TCM Core to release underlying fabric descriptor
diff --git a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.h b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.h
index 48e9b8b..dc7e48a 100644
--- a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.h
+++ b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.h
@@ -26,7 +26,6 @@ extern void tcm_qla2xxx_release_fabric_acl(struct se_portal_group *, struct se_n
 extern u32 tcm_qla2xxx_tpg_get_inst_index(struct se_portal_group *);
 extern void tcm_qla2xxx_free_cmd(struct qla_tgt_cmd *);
 extern int tcm_qla2xxx_check_stop_free(struct se_cmd *);
-extern int tcm_qla2xxx_check_release_cmd(struct se_cmd *);
 extern void tcm_qla2xxx_release_cmd(struct se_cmd *);
 extern int tcm_qla2xxx_shutdown_session(struct se_session *);
 extern void tcm_qla2xxx_close_session(struct se_session *);
-- 
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