Commit e8205cca authored by Varun Prakash's avatar Varun Prakash Committed by Nicholas Bellinger

iscsi-target: split iscsi_target_rx_thread()

split iscsi_target_rx_thread() into two parts,
1. iscsi_target_rx_thread() is common to all
   transport drivers, it will call Rx function
   registered by transport driver.

2. iscsit_get_rx_pdu() is Rx function for
   ISCSI_TCP transport.
Signed-off-by: default avatarVarun Prakash <varun@chelsio.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 187e84f7
...@@ -480,6 +480,7 @@ int iscsit_del_np(struct iscsi_np *np) ...@@ -480,6 +480,7 @@ int iscsit_del_np(struct iscsi_np *np)
static int iscsit_immediate_queue(struct iscsi_conn *, struct iscsi_cmd *, int); static int iscsit_immediate_queue(struct iscsi_conn *, struct iscsi_cmd *, int);
static int iscsit_response_queue(struct iscsi_conn *, struct iscsi_cmd *, int); static int iscsit_response_queue(struct iscsi_conn *, struct iscsi_cmd *, int);
static void iscsit_get_rx_pdu(struct iscsi_conn *);
static int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd) static int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
{ {
...@@ -682,6 +683,7 @@ static struct iscsit_transport iscsi_target_transport = { ...@@ -682,6 +683,7 @@ static struct iscsit_transport iscsi_target_transport = {
.iscsit_queue_status = iscsit_queue_rsp, .iscsit_queue_status = iscsit_queue_rsp,
.iscsit_aborted_task = iscsit_aborted_task, .iscsit_aborted_task = iscsit_aborted_task,
.iscsit_xmit_pdu = iscsit_xmit_pdu, .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_get_sup_prot_ops = iscsit_get_sup_prot_ops,
}; };
...@@ -3931,30 +3933,12 @@ static bool iscsi_target_check_conn_state(struct iscsi_conn *conn) ...@@ -3931,30 +3933,12 @@ static bool iscsi_target_check_conn_state(struct iscsi_conn *conn)
return ret; return ret;
} }
int iscsi_target_rx_thread(void *arg) static void iscsit_get_rx_pdu(struct iscsi_conn *conn)
{ {
int ret, rc; int ret;
u8 buffer[ISCSI_HDR_LEN], opcode; u8 buffer[ISCSI_HDR_LEN], opcode;
u32 checksum = 0, digest = 0; u32 checksum = 0, digest = 0;
struct iscsi_conn *conn = arg;
struct kvec iov; struct kvec iov;
/*
* Allow ourselves to be interrupted by SIGINT so that a
* connection recovery / failure event can be triggered externally.
*/
allow_signal(SIGINT);
/*
* Wait for iscsi_post_login_handler() to complete before allowing
* incoming iscsi/tcp socket I/O, and/or failing the connection.
*/
rc = wait_for_completion_interruptible(&conn->rx_login_comp);
if (rc < 0 || iscsi_target_check_conn_state(conn))
return 0;
if (conn->conn_transport->iscsit_get_rx_pdu) {
conn->conn_transport->iscsit_get_rx_pdu(conn);
goto transport_err;
}
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
/* /*
...@@ -3972,7 +3956,7 @@ int iscsi_target_rx_thread(void *arg) ...@@ -3972,7 +3956,7 @@ int iscsi_target_rx_thread(void *arg)
ret = rx_data(conn, &iov, 1, ISCSI_HDR_LEN); ret = rx_data(conn, &iov, 1, ISCSI_HDR_LEN);
if (ret != ISCSI_HDR_LEN) { if (ret != ISCSI_HDR_LEN) {
iscsit_rx_thread_wait_for_tcp(conn); iscsit_rx_thread_wait_for_tcp(conn);
goto transport_err; return;
} }
if (conn->conn_ops->HeaderDigest) { if (conn->conn_ops->HeaderDigest) {
...@@ -3982,7 +3966,7 @@ int iscsi_target_rx_thread(void *arg) ...@@ -3982,7 +3966,7 @@ int iscsi_target_rx_thread(void *arg)
ret = rx_data(conn, &iov, 1, ISCSI_CRC_LEN); ret = rx_data(conn, &iov, 1, ISCSI_CRC_LEN);
if (ret != ISCSI_CRC_LEN) { if (ret != ISCSI_CRC_LEN) {
iscsit_rx_thread_wait_for_tcp(conn); iscsit_rx_thread_wait_for_tcp(conn);
goto transport_err; return;
} }
iscsit_do_crypto_hash_buf(conn->conn_rx_hash, iscsit_do_crypto_hash_buf(conn->conn_rx_hash,
...@@ -4006,7 +3990,7 @@ int iscsi_target_rx_thread(void *arg) ...@@ -4006,7 +3990,7 @@ int iscsi_target_rx_thread(void *arg)
} }
if (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT) if (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT)
goto transport_err; return;
opcode = buffer[0] & ISCSI_OPCODE_MASK; opcode = buffer[0] & ISCSI_OPCODE_MASK;
...@@ -4017,15 +4001,38 @@ int iscsi_target_rx_thread(void *arg) ...@@ -4017,15 +4001,38 @@ int iscsi_target_rx_thread(void *arg)
" while in Discovery Session, rejecting.\n", opcode); " while in Discovery Session, rejecting.\n", opcode);
iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR,
buffer); buffer);
goto transport_err; return;
} }
ret = iscsi_target_rx_opcode(conn, buffer); ret = iscsi_target_rx_opcode(conn, buffer);
if (ret < 0) if (ret < 0)
goto transport_err; return;
} }
}
int iscsi_target_rx_thread(void *arg)
{
int rc;
struct iscsi_conn *conn = arg;
/*
* Allow ourselves to be interrupted by SIGINT so that a
* connection recovery / failure event can be triggered externally.
*/
allow_signal(SIGINT);
/*
* Wait for iscsi_post_login_handler() to complete before allowing
* incoming iscsi/tcp socket I/O, and/or failing the connection.
*/
rc = wait_for_completion_interruptible(&conn->rx_login_comp);
if (rc < 0 || iscsi_target_check_conn_state(conn))
return 0;
if (!conn->conn_transport->iscsit_get_rx_pdu)
return 0;
conn->conn_transport->iscsit_get_rx_pdu(conn);
transport_err:
if (!signal_pending(current)) if (!signal_pending(current))
atomic_set(&conn->transport_failed, 1); atomic_set(&conn->transport_failed, 1);
iscsit_take_action_for_connection_exit(conn); iscsit_take_action_for_connection_exit(conn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment