Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/iscsi Use correct lock for session wakeup.



details:   https://anonhg.NetBSD.org/src/rev/290e444545c0
branches:  trunk
changeset: 822001:290e444545c0
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Feb 25 12:03:57 2017 +0000

description:
Use correct lock for session wakeup.

diffstat:

 sys/dev/iscsi/iscsi_ioctl.c |  22 +++++++++++++++-------
 sys/dev/iscsi/iscsi_send.c  |   8 +-------
 2 files changed, 16 insertions(+), 14 deletions(-)

diffs (91 lines):

diff -r bbaecef728e4 -r 290e444545c0 sys/dev/iscsi/iscsi_ioctl.c
--- a/sys/dev/iscsi/iscsi_ioctl.c       Sat Feb 25 07:55:06 2017 +0000
+++ b/sys/dev/iscsi/iscsi_ioctl.c       Sat Feb 25 12:03:57 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsi_ioctl.c,v 1.24 2017/02/05 12:05:46 mlelstv Exp $ */
+/*     $NetBSD: iscsi_ioctl.c,v 1.25 2017/02/25 12:03:57 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -464,12 +464,12 @@
 unref_session(session_t *session)
 {
 
-       mutex_enter(&iscsi_cleanup_mtx);
+       mutex_enter(&session->lock);
        KASSERT(session != NULL);
        KASSERT(session->refcount > 0);
        if (--session->refcount == 0)
                cv_broadcast(&session->sess_cv);
-       mutex_exit(&iscsi_cleanup_mtx);
+       mutex_exit(&session->lock);
 }
 
 
@@ -811,11 +811,11 @@
                return -1;
        }
 
-       mutex_enter(&session->lock);
+       mutex_enter(&iscsi_cleanup_mtx);
        if (session->terminating) {
+               mutex_exit(&iscsi_cleanup_mtx);
                DEBC(connection, 0, ("Session terminating\n"));
                kill_connection(connection, rc, NO_LOGOUT, FALSE);
-               mutex_exit(&session->lock);
                par->status = session->terminating;
                return -1;
        }
@@ -825,7 +825,7 @@
        session->total_connections++;
        session->active_connections++;
        session->mru_connection = connection;
-       mutex_exit(&session->lock);
+       mutex_exit(&iscsi_cleanup_mtx);
 
        DEBC(connection, 5, ("Connection created successfully!\n"));
        return 0;
@@ -1630,12 +1630,20 @@
 }
 
 /*
- * add a connection to the cleanup list
+ * remove a connection from session and add to the cleanup list
  */
 void
 add_connection_cleanup(connection_t *conn)
 {
+       session_t *sess;
+
        mutex_enter(&iscsi_cleanup_mtx);
+       if (conn->in_session) {
+               sess = conn->session;
+               conn->in_session = FALSE;
+               TAILQ_REMOVE(&sess->conn_list, conn, connections);
+               sess->mru_connection = TAILQ_FIRST(&sess->conn_list);
+       }
        TAILQ_INSERT_TAIL(&iscsi_cleanupc_list, conn, connections);
        iscsi_notify_cleanup();
        mutex_exit(&iscsi_cleanup_mtx);
diff -r bbaecef728e4 -r 290e444545c0 sys/dev/iscsi/iscsi_send.c
--- a/sys/dev/iscsi/iscsi_send.c        Sat Feb 25 07:55:06 2017 +0000
+++ b/sys/dev/iscsi/iscsi_send.c        Sat Feb 25 12:03:57 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsi_send.c,v 1.33 2017/02/05 12:05:46 mlelstv Exp $  */
+/*     $NetBSD: iscsi_send.c,v 1.34 2017/02/25 12:03:57 mlelstv Exp $  */
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -419,12 +419,6 @@
                /* NOTE: wake_ccb will remove the CCB from the queue */
        }
 
-       if (conn->in_session) {
-               conn->in_session = FALSE;
-               TAILQ_REMOVE(&sess->conn_list, conn, connections);
-               sess->mru_connection = TAILQ_FIRST(&sess->conn_list);
-       }
-
        add_connection_cleanup(conn);
 
        conn->sendproc = NULL;



Home | Main Index | Thread Index | Old Index