Skip to contentSkip to conversation

iscsi_tcp: consider session state in iscsi_sw_sk_state_check

PATCH Superseded Chris Leech 2 participants 2 messages Jul 23, 2013 – Jul 25, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Chris Leech

author maintainer
#0 lore raw

PATCH 1/1 iscsi_tcp: consider session state in iscsi_sw_sk_state_check

It seems some iSCSI targets (including the Linux kernel target) close the TCP connection from the target side immediately after processing a session logout.

When a TCP FIN comes in right after the iSCSI logout response, iscsi_sw_sk_state_check sees the local socket as not yet being in CLOSE_WAIT or CLOSE and logs an error. But the initiator would close the connection right after processing the logout response anyway, and the error is confusing to admins who just requested that the session be shut down.

This adds a check of the session state, and suppresses the error if we are in the process of logging out.

---
 drivers/scsi/iscsi_tcp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/iscsi_tcp.c +1 -0
index 9e2588a..add6d15 100644
@@ -116,6 +116,7 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
 	struct iscsi_conn *conn = sk->sk_user_data;
 
 	if ((sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) &&
+	    (conn->session->state != ISCSI_STATE_LOGGING_OUT) &&
 	    !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);
Signature · 1 line
1.8.1.4

A message that is not in the archive (sent off-list or not yet received): 1374615728-11056-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 25 lines · Chris Leech

It seems some iSCSI targets (including the Linux kernel target) close the TCP connection from the target side immediately after processing a session logout.

When a TCP FIN comes in right after the iSCSI logout response, iscsi_sw_sk_state_check sees the local socket as not yet being in CLOSE_WAIT or CLOSE and logs an error. But the initiator would close the connection right after processing the logout response anyway, and the error is confusing to admins who just requested that the session be shut down.

This adds a check of the session state, and suppresses the error if we are in the process of logging out.

---
 drivers/scsi/iscsi_tcp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/iscsi_tcp.c +0 -0
index 9e2588a..add6d15 100644

drivers/scsi/iscsi_tcp.c static inline int iscsi_sw_sk_state_check(struct sock *sk) · line 122

Quoted 7 lines
drivers/scsi/iscsi_tcp.c +1 -0
@@ -116,6 +116,7 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
 	struct iscsi_conn *conn = sk->sk_user_data;
 
 	if ((sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) &&
+	    (conn->session->state != ISCSI_STATE_LOGGING_OUT) &&
 	    !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);

My only concern with the patch is what happens if the target closes connection due to a logout processing error. The logout timeout will kick in so we do not hang, but the patch makes it harder to debug those type of problems. I think the annoyance that this error message causes is higher than those concerns though since that happens so rarely now. So patch is ok with me.

Signature · 5 lines
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.