summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2016-06-05 05:18:58 +0000
committermlelstv <mlelstv@NetBSD.org>2016-06-05 05:18:58 +0000
commitbca24516c3bc73778f62154dbfe613281497e8f7 (patch)
tree6dc3a13e2c6395995c79641f793b54eda8a1580d /sys/dev
parent9bfc90c705f0aa31e9e05a0d9afa5e18e7ebedf7 (diff)
Fix locking for pdu flags here, in particular PDUF_INQUEUE.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/iscsi/iscsi_send.c16
-rw-r--r--sys/dev/iscsi/iscsi_utils.c11
2 files changed, 14 insertions, 13 deletions
diff --git a/sys/dev/iscsi/iscsi_send.c b/sys/dev/iscsi/iscsi_send.c
index a5281a67dfa..89443047e85 100644
--- a/sys/dev/iscsi/iscsi_send.c
+++ b/sys/dev/iscsi/iscsi_send.c
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_send.c,v 1.21 2016/06/05 04:36:05 mlelstv Exp $ */
+/* $NetBSD: iscsi_send.c,v 1.22 2016/06/05 05:18:58 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -190,6 +190,8 @@ reassign_tasks(connection_t *oldconn)
TAILQ_REMOVE(&oldconn->ccbs_waiting, ccb, chain);
opdu = ccb->pdu_waiting;
+ KASSERT((opdu->flags & PDUF_INQUEUE) == 0);
+
*pdu = *opdu;
/* restore overwritten back ptr */
@@ -303,7 +305,6 @@ iscsi_send_thread(void *par)
while (!conn->terminating &&
(pdu = TAILQ_FIRST(&conn->pdus_to_send)) != NULL) {
TAILQ_REMOVE(&conn->pdus_to_send, pdu, send_chain);
- pdu->flags &= ~PDUF_INQUEUE;
mutex_exit(&conn->lock);
KASSERT(!pdu->uio.uio_resid);
@@ -318,10 +319,15 @@ iscsi_send_thread(void *par)
ntohl(pdu->pdu.p.command.CmdSN)));
my_soo_write(conn, &pdu->uio);
- if (pdu->disp <= PDUDISP_FREE) {
+ mutex_enter(&conn->lock);
+ pdu->flags &= ~PDUF_INQUEUE;
+ if (pdu->disp > PDUDISP_FREE)
+ pdu->flags &= ~PDUF_BUSY;
+ mutex_exit(&conn->lock);
+
+ if (pdu->disp <= PDUDISP_FREE)
free_pdu(pdu);
- } else {
- pdu->flags &= ~PDUF_BUSY; }
+
mutex_enter(&conn->lock);
}
diff --git a/sys/dev/iscsi/iscsi_utils.c b/sys/dev/iscsi/iscsi_utils.c
index 422580a585b..6a515993d38 100644
--- a/sys/dev/iscsi/iscsi_utils.c
+++ b/sys/dev/iscsi/iscsi_utils.c
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_utils.c,v 1.13 2016/06/05 04:48:17 mlelstv Exp $ */
+/* $NetBSD: iscsi_utils.c,v 1.14 2016/06/05 05:18:58 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc.
@@ -504,17 +504,12 @@ free_pdu(pdu_t *pdu)
connection_t *conn = pdu->connection;
pdu_disp_t pdisp;
+ KASSERT((pdu->flags & PDUF_INQUEUE) == 0);
+
if (PDUDISP_UNUSED == (pdisp = pdu->disp))
return;
pdu->disp = PDUDISP_UNUSED;
- mutex_enter(&conn->lock);
- if (pdu->flags & PDUF_INQUEUE) {
- TAILQ_REMOVE(&conn->pdus_to_send, pdu, send_chain);
- pdu->flags &= ~PDUF_INQUEUE;
- }
- mutex_exit(&conn->lock);
-
/* free temporary data in this PDU */
if (pdu->temp_data)
free(pdu->temp_data, M_TEMP);