[PATCH 1/2] iscsi-target: Add iscsit_wait_conn() simulation for testing

From: Nicholas Bellinger
Date: Tue Oct 09 2018 - 04:57:53 EST


Simulate sess_tearing_down put in iscsit_queue_rsp following how
iser-target isert_put_cmd() works.

Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
---
drivers/target/iscsi/iscsi_target.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index cc756a1..b05d8af 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -485,6 +485,22 @@ int iscsit_del_np(struct iscsi_np *np)

int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
{
+ if (conn && conn->sess && conn->sess->se_sess) {
+ struct se_session *se_sess = conn->sess->se_sess;
+
+ if (se_sess->sess_tearing_down) {
+ printk("Got iscsit_queue_rsp sess_tearing_down !!!!!!\n");
+
+ spin_lock_bh(&conn->cmd_lock);
+ if (!list_empty(&cmd->i_conn_node))
+ list_del_init(&cmd->i_conn_node);
+ spin_unlock_bh(&conn->cmd_lock);
+
+ transport_generic_free_cmd(&cmd->se_cmd, 0);
+ return 0;
+ }
+ }
+
return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
}
EXPORT_SYMBOL(iscsit_queue_rsp);
@@ -667,6 +683,16 @@ static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsi_conn *conn)
return TARGET_PROT_NORMAL;
}

+static void iscsit_wait_conn(struct iscsi_conn *conn)
+{
+ if (conn->sess) {
+ target_sess_cmd_list_set_waiting(conn->sess->se_sess);
+ printk("se_sess: %p before target_wait_for_sess_cmds\n", conn->sess->se_sess);
+ target_wait_for_sess_cmds(conn->sess->se_sess);
+ printk("se_sess: %p after target_wait_for_sess_cmds\n", conn->sess->se_sess);
+ }
+}
+
static struct iscsit_transport iscsi_target_transport = {
.name = "iSCSI/TCP",
.transport_type = ISCSI_TCP,
@@ -686,6 +712,7 @@ static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsi_conn *conn)
.iscsit_xmit_pdu = iscsit_xmit_pdu,
.iscsit_get_rx_pdu = iscsit_get_rx_pdu,
.iscsit_get_sup_prot_ops = iscsit_get_sup_prot_ops,
+ .iscsit_wait_conn = iscsit_wait_conn,
};

static int __init iscsi_target_init_module(void)
--
1.9.1


--=-mAJjcxyyMXpcSErrgYWS
Content-Disposition: attachment;
filename*0=0002-target-iblock-Delayed-bios-for-active-I-O-shutdown-t.pat;
filename*1=ch
Content-Type: text/x-patch;
name="0002-target-iblock-Delayed-bios-for-active-I-O-shutdown-t.patch";
charset="ISO-8859-15"
Content-Transfer-Encoding: 7bit