Commit d1af8a32 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] iscsi_tcp: add new conn error to indicate tcp conn closed

If a target closed the connection, we will detect it in the
state_changed or data_ready callout. This adds a new conn
error value to use for this problem, so it is not confused
with when the initiator throws a conn error and drops
the connection.
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 632248aa
...@@ -109,11 +109,14 @@ static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, ...@@ -109,11 +109,14 @@ static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
*/ */
static inline int iscsi_sw_sk_state_check(struct sock *sk) static inline int iscsi_sw_sk_state_check(struct sock *sk)
{ {
if ((sk->sk_state == TCP_CLOSE_WAIT || struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data;
sk->sk_state == TCP_CLOSE) &&
!atomic_read(&sk->sk_rmem_alloc))
return -ECONNRESET;
if ((sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) &&
!atomic_read(&sk->sk_rmem_alloc)) {
ISCSI_SW_TCP_DBG(conn, "TCP_CLOSE|TCP_CLOSE_WAIT\n");
iscsi_conn_failure(conn, ISCSI_ERR_TCP_CONN_CLOSE);
return -ECONNRESET;
}
return 0; return 0;
} }
...@@ -135,11 +138,7 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag) ...@@ -135,11 +138,7 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag)
rd_desc.count = 1; rd_desc.count = 1;
tcp_read_sock(sk, &rd_desc, iscsi_sw_tcp_recv); tcp_read_sock(sk, &rd_desc, iscsi_sw_tcp_recv);
if (iscsi_sw_sk_state_check(sk) < 0) { iscsi_sw_sk_state_check(sk);
ISCSI_SW_TCP_DBG(conn, "iscsi_tcp_data_ready: "
"TCP_CLOSE|TCP_CLOSE_WAIT\n");
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
}
read_unlock(&sk->sk_callback_lock); read_unlock(&sk->sk_callback_lock);
...@@ -161,11 +160,7 @@ static void iscsi_sw_tcp_state_change(struct sock *sk) ...@@ -161,11 +160,7 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
conn = (struct iscsi_conn*)sk->sk_user_data; conn = (struct iscsi_conn*)sk->sk_user_data;
session = conn->session; session = conn->session;
if (iscsi_sw_sk_state_check(sk) < 0) { iscsi_sw_sk_state_check(sk);
ISCSI_SW_TCP_DBG(conn, "iscsi_tcp_state_change: "
"TCP_CLOSE|TCP_CLOSE_WAIT\n");
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
}
tcp_conn = conn->dd_data; tcp_conn = conn->dd_data;
tcp_sw_conn = tcp_conn->dd_data; tcp_sw_conn = tcp_conn->dd_data;
......
...@@ -262,6 +262,7 @@ enum iscsi_err { ...@@ -262,6 +262,7 @@ enum iscsi_err {
ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17, ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18, ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
}; };
/* /*
......
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