Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/iscsi Pull up following revision(s) (requested by...
details: https://anonhg.NetBSD.org/src/rev/780b1f322453
branches: netbsd-8
changeset: 434493:780b1f322453
user: snj <snj%NetBSD.org@localhost>
date: Thu Dec 21 19:17:43 2017 +0000
description:
Pull up following revision(s) (requested by mlelstv in ticket #437):
sys/dev/iscsi/iscsi_ioctl.c: 1.26-1.27
sys/dev/iscsi/iscsi_main.c: 1.26
sys/dev/iscsi/iscsi_send.c: 1.35
Fix session cleanup.
--
add debug messages
-
use same lock for ref/deref.
--
unreference session only for responses to SCSI commands.
diffstat:
sys/dev/iscsi/iscsi_ioctl.c | 32 +++++++++++++++++++++-----------
sys/dev/iscsi/iscsi_main.c | 5 +++--
sys/dev/iscsi/iscsi_send.c | 12 +++++++++---
3 files changed, 33 insertions(+), 16 deletions(-)
diffs (168 lines):
diff -r 0f71666feb5a -r 780b1f322453 sys/dev/iscsi/iscsi_ioctl.c
--- a/sys/dev/iscsi/iscsi_ioctl.c Thu Dec 21 19:14:41 2017 +0000
+++ b/sys/dev/iscsi/iscsi_ioctl.c Thu Dec 21 19:17:43 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.25.6.1 2017/12/21 19:17:43 snj Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -464,12 +464,12 @@
unref_session(session_t *session)
{
- mutex_enter(&session->lock);
+ mutex_enter(&iscsi_cleanup_mtx);
KASSERT(session != NULL);
KASSERT(session->refcount > 0);
if (--session->refcount == 0)
cv_broadcast(&session->sess_cv);
- mutex_exit(&session->lock);
+ mutex_exit(&iscsi_cleanup_mtx);
}
@@ -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);
}
diff -r 0f71666feb5a -r 780b1f322453 sys/dev/iscsi/iscsi_main.c
--- a/sys/dev/iscsi/iscsi_main.c Thu Dec 21 19:14:41 2017 +0000
+++ b/sys/dev/iscsi/iscsi_main.c Thu Dec 21 19:17:43 2017 +0000
@@ -558,6 +558,7 @@
DEB(9, ("iscsi_done\n"));
if (xs != NULL) {
+ ccb->xs = NULL;
xs->resid = ccb->residual;
switch (ccb->status) {
@@ -595,14 +596,14 @@
break;
}
+ unref_session(ccb->session);
+
DEB(99, ("Calling scsipi_done (%p), err = %d\n", xs, xs->error));
scsipi_done(xs);
DEB(99, ("scsipi_done returned\n"));
} else {
DEBOUT(("ISCSI: iscsi_done CCB %p without XS\n", ccb));
}
-
- unref_session(ccb->session);
}
SYSCTL_SETUP(sysctl_iscsi_setup, "ISCSI subtree setup")
diff -r 0f71666feb5a -r 780b1f322453 sys/dev/iscsi/iscsi_send.c
--- a/sys/dev/iscsi/iscsi_send.c Thu Dec 21 19:14:41 2017 +0000
+++ b/sys/dev/iscsi/iscsi_send.c Thu Dec 21 19:17:43 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_send.c,v 1.34 2017/02/25 12:03:57 mlelstv Exp $ */
+/* $NetBSD: iscsi_send.c,v 1.34.6.1 2017/12/21 19:17:43 snj Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -395,7 +395,7 @@
/* notify event handlers of connection shutdown */
DEBC(conn, 1, ("%s\n", (conn->destroy) ? "TERMINATED" : "RECOVER"));
add_event((conn->destroy) ? ISCSI_CONNECTION_TERMINATED
- : ISCSI_RECOVER_CONNECTION,
+ : ISCSI_RECOVER_CONNECTION,
sess->id, conn->id, conn->terminating);
DEBC(conn, 1, ("Waiting for conn_idle\n"));
@@ -1251,10 +1251,15 @@
ccb = get_ccb(conn, xs == NULL);
/* can only happen if terminating... */
- if (ccb == NULL)
+ if (ccb == NULL) {
+ DEBC(conn, 0, ("send_task_management, ref_ccb=%p, xs=%p, term=%d. No CCB\n",
+ ref_ccb, xs, conn->terminating));
return conn->terminating;
+ }
ppdu = get_pdu(conn, xs == NULL);
if (ppdu == NULL) {
+ DEBC(conn, 0, ("send_task_management, ref_ccb=%p, xs=%p, term=%d. No PDU\n",
+ ref_ccb, xs, conn->terminating));
free_ccb(ccb);
return conn->terminating;
}
@@ -1489,6 +1494,7 @@
if (xs->xs_control & XS_CTL_RESET) {
if (send_task_management(conn, NULL, xs, TARGET_WARM_RESET)) {
+ DEBC(conn, 0, ("send_task_management TARGET_WARM_RESET failed\n"));
xs->error = XS_SELTIMEOUT;
scsipi_done(xs);
unref_session(session);
Home |
Main Index |
Thread Index |
Old Index