Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/iscsi Destroy callouts when cleaning up.
details: https://anonhg.NetBSD.org/src/rev/0d169865f1b0
branches: trunk
changeset: 351190:0d169865f1b0
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Feb 05 12:05:46 2017 +0000
description:
Destroy callouts when cleaning up.
diffstat:
sys/dev/iscsi/iscsi_globals.h | 3 ++-
sys/dev/iscsi/iscsi_ioctl.c | 14 ++++++++++----
sys/dev/iscsi/iscsi_send.c | 5 ++++-
sys/dev/iscsi/iscsi_utils.c | 30 +++++++++++++++++++++++++++++-
4 files changed, 45 insertions(+), 7 deletions(-)
diffs (172 lines):
diff -r 343e1ba1a7c8 -r 0d169865f1b0 sys/dev/iscsi/iscsi_globals.h
--- a/sys/dev/iscsi/iscsi_globals.h Sun Feb 05 10:42:21 2017 +0000
+++ b/sys/dev/iscsi/iscsi_globals.h Sun Feb 05 12:05:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_globals.h,v 1.21 2016/06/15 04:30:30 mlelstv Exp $ */
+/* $NetBSD: iscsi_globals.h,v 1.22 2017/02/05 12:05:46 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -717,6 +717,7 @@
uint32_t gen_digest_2(void *, int, void *, int);
void create_ccbs(session_t *);
+void destroy_ccbs(session_t *);
ccb_t *get_ccb(connection_t *, bool);
void free_ccb(ccb_t *);
void suspend_ccb(ccb_t *, bool);
diff -r 343e1ba1a7c8 -r 0d169865f1b0 sys/dev/iscsi/iscsi_ioctl.c
--- a/sys/dev/iscsi/iscsi_ioctl.c Sun Feb 05 10:42:21 2017 +0000
+++ b/sys/dev/iscsi/iscsi_ioctl.c Sun Feb 05 12:05:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_ioctl.c,v 1.23 2016/12/25 06:55:28 mlelstv Exp $ */
+/* $NetBSD: iscsi_ioctl.c,v 1.24 2017/02/05 12:05:46 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -727,6 +727,7 @@
if ((rc = get_socket(par->socket, &connection->sock)) != 0) {
DEBOUT(("Invalid socket %d\n", par->socket));
+ callout_destroy(&connection->timeout);
cv_destroy(&connection->idle_cv);
cv_destroy(&connection->ccb_cv);
cv_destroy(&connection->pdu_cv);
@@ -752,6 +753,7 @@
DEBOUT(("Can't create rcv thread (rc %d)\n", rc));
release_socket(connection->sock);
+ callout_destroy(&connection->timeout);
cv_destroy(&connection->idle_cv);
cv_destroy(&connection->ccb_cv);
cv_destroy(&connection->pdu_cv);
@@ -784,6 +786,7 @@
kpause("settle", false, 2 * hz, NULL);
release_socket(connection->sock);
+ callout_destroy(&connection->timeout);
cv_destroy(&connection->idle_cv);
cv_destroy(&connection->ccb_cv);
cv_destroy(&connection->pdu_cv);
@@ -1094,6 +1097,7 @@
if ((rc = create_connection(par, session, l)) != 0) {
if (rc > 0) {
+ destroy_ccbs(session);
cv_destroy(&session->ccb_cv);
cv_destroy(&session->sess_cv);
mutex_destroy(&session->lock);
@@ -1666,7 +1670,7 @@
void
connection_timeout_stop(connection_t *conn)
{
- callout_halt(&conn->timeout, NULL);
+ callout_stop(&conn->timeout);
mutex_enter(&iscsi_cleanup_mtx);
if (conn->timedout == TOUT_QUEUED) {
TAILQ_REMOVE(&iscsi_timeout_conn_list, conn, tchain);
@@ -1705,7 +1709,7 @@
void
ccb_timeout_stop(ccb_t *ccb)
{
- callout_halt(&ccb->timeout, NULL);
+ callout_stop(&ccb->timeout);
mutex_enter(&iscsi_cleanup_mtx);
if (ccb->timedout == TOUT_QUEUED) {
TAILQ_REMOVE(&iscsi_timeout_ccb_list, ccb, tchain);
@@ -1762,8 +1766,9 @@
KASSERT(!conn->in_session);
- callout_halt(&conn->timeout, NULL);
+ callout_halt(&conn->timeout, &iscsi_cleanup_mtx);
closef(conn->sock);
+ callout_destroy(&conn->timeout);
cv_destroy(&conn->idle_cv);
cv_destroy(&conn->ccb_cv);
cv_destroy(&conn->pdu_cv);
@@ -1810,6 +1815,7 @@
add_event(ISCSI_SESSION_TERMINATED, sess->id, 0, sess->terminating);
DEB(1, ("Cleanup: session ended %d\n", sess->id));
+ destroy_ccbs(sess);
cv_destroy(&sess->ccb_cv);
cv_destroy(&sess->sess_cv);
mutex_destroy(&sess->lock);
diff -r 343e1ba1a7c8 -r 0d169865f1b0 sys/dev/iscsi/iscsi_send.c
--- a/sys/dev/iscsi/iscsi_send.c Sun Feb 05 10:42:21 2017 +0000
+++ b/sys/dev/iscsi/iscsi_send.c Sun Feb 05 12:05:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_send.c,v 1.32 2016/12/25 06:55:28 mlelstv Exp $ */
+/* $NetBSD: iscsi_send.c,v 1.33 2017/02/05 12:05:46 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1489,6 +1489,7 @@
xs->error = XS_SELTIMEOUT;
DEBC(conn, 10, ("run_xfer on dead connection\n"));
scsipi_done(xs);
+ unref_session(session);
return;
}
@@ -1496,6 +1497,7 @@
if (send_task_management(conn, NULL, xs, TARGET_WARM_RESET)) {
xs->error = XS_SELTIMEOUT;
scsipi_done(xs);
+ unref_session(session);
}
return;
}
@@ -1505,6 +1507,7 @@
xs->error = XS_BUSY;
DEBC(conn, 5, ("No CCB in run_xfer, %d in use.\n", conn->usecount));
scsipi_done(xs);
+ unref_session(session);
return;
}
/* copy parameters into CCB for easier access */
diff -r 343e1ba1a7c8 -r 0d169865f1b0 sys/dev/iscsi/iscsi_utils.c
--- a/sys/dev/iscsi/iscsi_utils.c Sun Feb 05 10:42:21 2017 +0000
+++ b/sys/dev/iscsi/iscsi_utils.c Sun Feb 05 12:05:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_utils.c,v 1.22 2016/12/25 06:55:28 mlelstv Exp $ */
+/* $NetBSD: iscsi_utils.c,v 1.23 2017/02/05 12:05:46 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc.
@@ -323,6 +323,34 @@
}
/*
+ * destroy_ccbs
+ * Kill the callouts
+ *
+ * Parameter: The session owning the CCBs.
+ */
+
+void
+destroy_ccbs(session_t *sess)
+{
+ int i;
+ ccb_t *ccb;
+
+ /* Note: CCBs are initialized to 0 with connection structure */
+
+ for (i = 0, ccb = sess->ccb; i < CCBS_PER_SESSION; i++, ccb++) {
+
+ callout_halt(&ccb->timeout, NULL);
+ callout_destroy(&ccb->timeout);
+
+ DEB(9, ("destroy_ccbs: ccb %p itt %x\n", ccb, ccb->ITT));
+ KASSERT((ccb->flags & CCBF_WAITQUEUE) == 0);
+ KASSERT(ccb->disp == CCBDISP_UNUSED);
+ KASSERT(ccb->connection == NULL);
+ TAILQ_REMOVE(&sess->ccb_pool, ccb, chain);
+ }
+}
+
+/*
* suspend_ccb:
* Put CCB on wait queue
*/
Home |
Main Index |
Thread Index |
Old Index