Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/iscsi refactor callouts
details: https://anonhg.NetBSD.org/src/rev/a50549da99e9
branches: trunk
changeset: 345582:a50549da99e9
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Wed Jun 01 05:13:07 2016 +0000
description:
refactor callouts
remove timed out ccbs and connections from cleanup queue when stopping timeout.
diffstat:
sys/dev/iscsi/iscsi_globals.h | 8 ++++++-
sys/dev/iscsi/iscsi_ioctl.c | 44 ++++++++++++++++++++++++++++++++++++++++--
sys/dev/iscsi/iscsi_rcv.c | 16 +++++++-------
sys/dev/iscsi/iscsi_send.c | 18 ++++++++--------
sys/dev/iscsi/iscsi_utils.c | 4 +-
5 files changed, 67 insertions(+), 23 deletions(-)
diffs (290 lines):
diff -r afd5393e5f8a -r a50549da99e9 sys/dev/iscsi/iscsi_globals.h
--- a/sys/dev/iscsi/iscsi_globals.h Wed Jun 01 05:11:52 2016 +0000
+++ b/sys/dev/iscsi/iscsi_globals.h Wed Jun 01 05:13:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_globals.h,v 1.15 2016/06/01 04:19:08 mlelstv Exp $ */
+/* $NetBSD: iscsi_globals.h,v 1.16 2016/06/01 05:13:07 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -253,6 +253,7 @@
struct callout timeout; /* To make sure it isn't lost */
TAILQ_ENTRY(ccb_s) tchain;
+ bool timedout;
int num_timeouts;
/* How often we've sent out SNACK without answer */
int total_tries;
@@ -373,6 +374,7 @@
struct callout timeout;
/* Timeout for checking if connection is dead */
TAILQ_ENTRY(connection_s) tchain;
+ bool timedout;
int num_timeouts;
/* How often we've sent out a NOP without answer */
uint32_t idle_timeout_val;
@@ -698,7 +700,11 @@
void ccb_timeout_co(void *);
void connection_timeout(connection_t *);
+void connection_timeout_start(connection_t *, int);
+void connection_timeout_stop(connection_t *);
void ccb_timeout(ccb_t *);
+void ccb_timeout_start(ccb_t *, int);
+void ccb_timeout_stop(ccb_t *);
/* in iscsi_rcv.c */
diff -r afd5393e5f8a -r a50549da99e9 sys/dev/iscsi/iscsi_ioctl.c
--- a/sys/dev/iscsi/iscsi_ioctl.c Wed Jun 01 05:11:52 2016 +0000
+++ b/sys/dev/iscsi/iscsi_ioctl.c Wed Jun 01 05:13:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_ioctl.c,v 1.15 2016/06/01 04:07:03 mlelstv Exp $ */
+/* $NetBSD: iscsi_ioctl.c,v 1.16 2016/06/01 05:13:07 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -497,7 +497,7 @@
/* of logging in */
if (logout >= 0) {
conn->state = ST_WINDING_DOWN;
- callout_schedule(&conn->timeout, CONNECTION_TIMEOUT);
+ connection_timeout_start(conn, CONNECTION_TIMEOUT);
if (sess->ErrorRecoveryLevel < 2 &&
logout == RECOVER_CONNECTION) {
@@ -887,7 +887,7 @@
mutex_exit(&session->lock);
resend_pdu(ccb);
} else {
- callout_schedule(&ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(ccb, COMMAND_TIMEOUT);
}
}
@@ -1576,22 +1576,60 @@
connection_t *conn = par;
mutex_enter(&iscsi_cleanup_mtx);
+ conn->timedout = true;
TAILQ_INSERT_TAIL(&iscsi_timeout_conn_list, conn, tchain);
mutex_exit(&iscsi_cleanup_mtx);
iscsi_notify_cleanup();
}
+void
+connection_timeout_start(connection_t *conn, int ticks)
+{
+ callout_schedule(&conn->timeout, ticks);
+}
+
+void
+connection_timeout_stop(connection_t *conn)
+{
+ callout_halt(&conn->timeout, NULL);
+ mutex_enter(&iscsi_cleanup_mtx);
+ if (conn->timedout) {
+ TAILQ_REMOVE(&iscsi_timeout_conn_list, conn, tchain);
+ conn->timedout = false;
+ }
+ mutex_exit(&iscsi_cleanup_mtx);
+}
+
void
ccb_timeout_co(void *par)
{
ccb_t *ccb = par;
mutex_enter(&iscsi_cleanup_mtx);
+ ccb->timedout = true;
TAILQ_INSERT_TAIL(&iscsi_timeout_ccb_list, ccb, tchain);
mutex_exit(&iscsi_cleanup_mtx);
iscsi_notify_cleanup();
}
+void
+ccb_timeout_start(ccb_t *ccb, int ticks)
+{
+ callout_schedule(&ccb->timeout, ticks);
+}
+
+void
+ccb_timeout_stop(ccb_t *ccb)
+{
+ callout_halt(&ccb->timeout, NULL);
+ mutex_enter(&iscsi_cleanup_mtx);
+ if (ccb->timedout) {
+ TAILQ_REMOVE(&iscsi_timeout_ccb_list, ccb, tchain);
+ ccb->timedout = false;
+ }
+ mutex_exit(&iscsi_cleanup_mtx);
+}
+
/*
* iscsi_cleanup_thread
* Global thread to handle connection and session cleanup after termination.
diff -r afd5393e5f8a -r a50549da99e9 sys/dev/iscsi/iscsi_rcv.c
--- a/sys/dev/iscsi/iscsi_rcv.c Wed Jun 01 05:11:52 2016 +0000
+++ b/sys/dev/iscsi/iscsi_rcv.c Wed Jun 01 05:13:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_rcv.c,v 1.11 2016/05/29 13:51:16 mlelstv Exp $ */
+/* $NetBSD: iscsi_rcv.c,v 1.12 2016/06/01 05:13:07 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -471,7 +471,7 @@
}
if (req_ccb->pdu_waiting != NULL) {
- callout_schedule(&req_ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(req_ccb, COMMAND_TIMEOUT);
req_ccb->num_timeouts = 0;
}
@@ -542,7 +542,7 @@
conn->state = ST_SETTLING;
conn->loggedout = (response) ? LOGOUT_FAILED : LOGOUT_SUCCESS;
- callout_stop(&conn->timeout);
+ connection_timeout_stop(conn);
/* let send thread take over next step of cleanup */
cv_broadcast(&conn->conn_cv);
@@ -578,7 +578,7 @@
req_ccb->flags |= CCBF_GOT_RSP;
if (req_ccb->pdu_waiting != NULL) {
- callout_schedule(&req_ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(req_ccb, COMMAND_TIMEOUT);
req_ccb->num_timeouts = 0;
}
@@ -659,7 +659,7 @@
if (req_ccb != NULL) {
if (req_ccb->pdu_waiting != NULL) {
- callout_schedule(&req_ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(req_ccb, COMMAND_TIMEOUT);
req_ccb->num_timeouts = 0;
}
send_data_out(conn, pdu, req_ccb, CCBDISP_NOWAIT, TRUE);
@@ -702,7 +702,7 @@
}
if (req_ccb->pdu_waiting != NULL) {
- callout_schedule(&req_ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(req_ccb, COMMAND_TIMEOUT);
req_ccb->num_timeouts = 0;
}
@@ -1095,9 +1095,9 @@
/* received a valid frame, reset timeout */
if ((pdu->pdu.Opcode & OPCODE_MASK) == TOP_NOP_In &&
TAILQ_EMPTY(&conn->ccbs_waiting))
- callout_schedule(&conn->timeout, conn->idle_timeout_val);
+ connection_timeout_start(conn, conn->idle_timeout_val);
else
- callout_schedule(&conn->timeout, CONNECTION_TIMEOUT);
+ connection_timeout_start(conn, CONNECTION_TIMEOUT);
conn->num_timeouts = 0;
/*
diff -r afd5393e5f8a -r a50549da99e9 sys/dev/iscsi/iscsi_send.c
--- a/sys/dev/iscsi/iscsi_send.c Wed Jun 01 05:11:52 2016 +0000
+++ b/sys/dev/iscsi/iscsi_send.c Wed Jun 01 05:13:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_send.c,v 1.17 2016/06/01 04:19:08 mlelstv Exp $ */
+/* $NetBSD: iscsi_send.c,v 1.18 2016/06/01 05:13:07 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -267,7 +267,7 @@
mutex_exit(&sess->lock);
resend_pdu(ccb);
} else {
- callout_schedule(&ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(ccb, COMMAND_TIMEOUT);
}
DEBC(conn, 1, ("Reassign ccb %p, no_tm=%d, rc=%d\n",
ccb, no_tm, rc));
@@ -333,7 +333,7 @@
* Here this thread takes over cleanup of the terminating connection.
* ------------------------------------------------------------------------
*/
- callout_stop(&conn->timeout);
+ connection_timeout_stop(conn);
conn->idle_timeout_val = CONNECTION_IDLE_TIMEOUT;
fp = conn->sock;
@@ -354,7 +354,7 @@
ccb,&ccb->timeout));
wake_ccb(ccb, conn->terminating);
} else {
- callout_stop(&ccb->timeout);
+ ccb_timeout_stop(ccb);
ccb->num_timeouts = 0;
}
}
@@ -377,7 +377,7 @@
/* If there's another connection available, transfer pending tasks */
if (sess->active_connections &&
TAILQ_FIRST(&conn->ccbs_waiting) != NULL) {
- DEBC(conn, 1, ("Reassign Tasks\n"));
+
reassign_tasks(conn);
} else if (!conn->destroy && conn->Time2Wait) {
DEBC(conn, 1, ("Time2Wait\n"));
@@ -478,7 +478,7 @@
cv_broadcast(&conn->conn_cv);
if (cdisp != CCBDISP_NOWAIT) {
- callout_schedule(&ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(ccb, COMMAND_TIMEOUT);
if (prev_cdisp <= CCBDISP_NOWAIT)
suspend_ccb(ccb, TRUE);
@@ -533,7 +533,7 @@
} else {
TAILQ_INSERT_TAIL(&conn->pdus_to_send, pdu, send_chain);
}
- callout_schedule(&ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(ccb, COMMAND_TIMEOUT);
mutex_exit(&conn->lock);
cv_broadcast(&conn->conn_cv);
@@ -1594,7 +1594,7 @@
if (conn->state == ST_FULL_FEATURE)
send_nop_out(conn, NULL);
- callout_schedule(&conn->timeout, CONNECTION_TIMEOUT);
+ connection_timeout_start(conn, CONNECTION_TIMEOUT);
}
}
@@ -1631,7 +1631,7 @@
/* request resend of all missing status */
snack_missing(conn, NULL, SNACK_STATUS_NAK, 0, 0);
}
- callout_schedule(&ccb->timeout, COMMAND_TIMEOUT);
+ ccb_timeout_start(ccb, COMMAND_TIMEOUT);
}
}
diff -r afd5393e5f8a -r a50549da99e9 sys/dev/iscsi/iscsi_utils.c
--- a/sys/dev/iscsi/iscsi_utils.c Wed Jun 01 05:11:52 2016 +0000
+++ b/sys/dev/iscsi/iscsi_utils.c Wed Jun 01 05:13:07 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_utils.c,v 1.10 2016/06/01 04:19:08 mlelstv Exp $ */
+/* $NetBSD: iscsi_utils.c,v 1.11 2016/06/01 05:13:07 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc.
@@ -403,7 +403,7 @@
ccb, ccb->disp));
#endif
- callout_stop(&ccb->timeout);
+ ccb_timeout_stop(ccb);
mutex_enter(&conn->lock);
disp = ccb->disp;
Home |
Main Index |
Thread Index |
Old Index