Try to shorten the race window where the initiator could drop the connection while we are performing login operations. Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx> --- drivers/target/iscsi/iscsi_target_login.c | 13 +++++++++++++ drivers/target/iscsi/iscsi_target_nego.c | 2 +- include/target/iscsi/iscsi_transport.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index d7d406e..dacb773 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -1119,6 +1119,19 @@ int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, u32 length) { + struct sock *sk = conn->sock->sk; + bool state; + + read_lock_bh(&sk->sk_callback_lock); + state = iscsi_target_sk_state_check(sk); + read_unlock_bh(&sk->sk_callback_lock); + + if (!state) { + pr_debug("iscsit_put_login_tx() failed state for conn: %p\n", + conn); + return -1; + } + if (iscsi_login_tx_data(conn, login->rsp, login->rsp_buf, length) < 0) return -1; diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index 9edac16..b81017f 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -492,7 +492,7 @@ static void iscsi_target_restore_sock_callbacks(struct iscsi_conn *conn) static int iscsi_target_do_login(struct iscsi_conn *, struct iscsi_login *); -static bool iscsi_target_sk_state_check(struct sock *sk) +bool iscsi_target_sk_state_check(struct sock *sk) { if (sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) { pr_debug("iscsi_target_sk_state_check: TCP_CLOSE_WAIT|TCP_CLOSE," diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h index b9a76ed..25d8b87 100644 --- a/include/target/iscsi/iscsi_transport.h +++ b/include/target/iscsi/iscsi_transport.h @@ -138,6 +138,7 @@ extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, */ extern int iscsi_target_check_login_request(struct iscsi_conn *, struct iscsi_login *); +extern bool iscsi_target_sk_state_check(struct sock *); /* * From iscsi_target_login.c -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html