[PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once

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

 



While releasing a command __iscsit_free_cmd() can be called multiple
times but .iscsit_release_cmd() must be called only once. Hence move
the .iscsit_release_cmd() call into iscsit_release_cmd(). The latter
function is only called once per command. The only driver that defines
the .iscsit_release_cmd() callback is the cxgbit driver so this change
only affects the cxgbit driver.

Fixes: 7ec811a8e9c3 ("iscsi-target: add void (*iscsit_release_cmd)()")
Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
Cc: Varun Prakash <varun@xxxxxxxxxxx>
Cc: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
---
 drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index 5041a9c8bdcb..8a022b5b2317 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -691,11 +691,17 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
 {
 	struct iscsi_session *sess;
 	struct se_cmd *se_cmd = &cmd->se_cmd;
+	struct iscsi_conn *conn = cmd->conn;
+	void (*release)(struct iscsi_conn *, struct iscsi_cmd *);
 
-	if (cmd->conn)
-		sess = cmd->conn->sess;
-	else
+	if (conn) {
+		sess = conn->sess;
+		release = conn->conn_transport->iscsit_release_cmd;
+		if (release)
+			release(conn, cmd);
+	} else {
 		sess = cmd->sess;
+	}
 
 	BUG_ON(!sess || !sess->se_sess);
 
@@ -728,9 +734,6 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd,
 		iscsit_remove_cmd_from_immediate_queue(cmd, conn);
 		iscsit_remove_cmd_from_response_queue(cmd, conn);
 	}
-
-	if (conn && conn->conn_transport->iscsit_release_cmd)
-		conn->conn_transport->iscsit_release_cmd(conn, cmd);
 }
 
 void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
-- 
2.12.0




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]