Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/iscsi Fix session cleanup.



details:   https://anonhg.NetBSD.org/src/rev/af73a513c275
branches:  trunk
changeset: 824966:af73a513c275
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Jun 24 11:31:26 2017 +0000

description:
Fix session cleanup.

diffstat:

 sys/dev/iscsi/iscsi_ioctl.c |  28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diffs (82 lines):

diff -r f9bdce6960a3 -r af73a513c275 sys/dev/iscsi/iscsi_ioctl.c
--- a/sys/dev/iscsi/iscsi_ioctl.c       Sat Jun 24 11:27:33 2017 +0000
+++ b/sys/dev/iscsi/iscsi_ioctl.c       Sat Jun 24 11:31:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsi_ioctl.c,v 1.25 2017/02/25 12:03:57 mlelstv Exp $ */
+/*     $NetBSD: iscsi_ioctl.c,v 1.26 2017/06/24 11:31:26 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -520,16 +520,19 @@
        terminating = conn->terminating;
        if (!terminating)
                conn->terminating = status;
-       mutex_exit(&iscsi_cleanup_mtx);
 
        /* Don't recurse */
        if (terminating) {
+               mutex_exit(&iscsi_cleanup_mtx);
+
+               KASSERT(conn->state != ST_FULL_FEATURE);
                DEBC(conn, 1, ("Kill_connection exiting (already terminating)\n"));
                goto done;
        }
 
        if (conn->state == ST_FULL_FEATURE) {
                sess->active_connections--;
+               conn->state = ST_WINDING_DOWN;
 
                /* If this is the last connection and ERL < 2, reset TSIH */
                if (!sess->active_connections && sess->ErrorRecoveryLevel < 2)
@@ -538,9 +541,6 @@
                /* Don't try to log out if the socket is broken or we're in the middle */
                /* of logging in */
                if (logout >= 0) {
-                       conn->state = ST_WINDING_DOWN;
-                       connection_timeout_start(conn, CONNECTION_TIMEOUT);
-
                        if (sess->ErrorRecoveryLevel < 2 &&
                            logout == RECOVER_CONNECTION) {
                                logout = LOGOUT_CONNECTION;
@@ -549,20 +549,29 @@
                            logout == LOGOUT_CONNECTION) {
                                logout = LOGOUT_SESSION;
                        }
+                       mutex_exit(&iscsi_cleanup_mtx);
+
+                       connection_timeout_start(conn, CONNECTION_TIMEOUT);
+
                        if (!send_logout(conn, conn, logout, FALSE)) {
                                conn->terminating = ISCSI_STATUS_SUCCESS;
                                return;
                        }
                        /*
-                        * if the logout request was successfully sent, the logout response
-                        * handler will do the rest of the termination processing. If the
-                        * logout doesn't get a response, we'll get back in here once
-                        * the timeout hits.
+                        * if the logout request was successfully sent,
+                        * the logout response handler will do the rest
+                        * of the termination processing. If the logout
+                        * doesn't get a response, we'll get back in here
+                        * once the timeout hits.
                         */
+
+                       mutex_enter(&iscsi_cleanup_mtx);
                }
+
        }
 
        conn->state = ST_SETTLING;
+       mutex_exit(&iscsi_cleanup_mtx);
 
 done:
        /* let send thread take over next step of cleanup */
@@ -1641,6 +1650,7 @@
        if (conn->in_session) {
                sess = conn->session;
                conn->in_session = FALSE;
+               conn->session = NULL;
                TAILQ_REMOVE(&sess->conn_list, conn, connections);
                sess->mru_connection = TAILQ_FIRST(&sess->conn_list);
        }



Home | Main Index | Thread Index | Old Index