Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/iscsi Handle freeing of PDU when referencing CCB is ...
details: https://anonhg.NetBSD.org/src/rev/937efa7e7874
branches: trunk
changeset: 345716:937efa7e7874
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Jun 05 13:54:28 2016 +0000
description:
Handle freeing of PDU when referencing CCB is freed.
diffstat:
sys/dev/iscsi/iscsi_send.c | 12 ++++++++----
sys/dev/iscsi/iscsi_utils.c | 15 +++++++++++----
2 files changed, 19 insertions(+), 8 deletions(-)
diffs (86 lines):
diff -r 56ce4e9974ce -r 937efa7e7874 sys/dev/iscsi/iscsi_send.c
--- a/sys/dev/iscsi/iscsi_send.c Sun Jun 05 13:45:56 2016 +0000
+++ b/sys/dev/iscsi/iscsi_send.c Sun Jun 05 13:54:28 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_send.c,v 1.29 2016/06/05 09:12:48 mlelstv Exp $ */
+/* $NetBSD: iscsi_send.c,v 1.30 2016/06/05 13:54:28 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -291,6 +291,7 @@
ccb_t *ccb, *nccb;
pdu_t *pdu;
struct file *fp;
+ pdu_disp_t pdisp;
sess = conn->session;
/* so cleanup thread knows there's someone left */
@@ -302,6 +303,7 @@
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);
/* update ExpStatSN here to avoid discontinuities */
@@ -315,12 +317,14 @@
my_soo_write(conn, &pdu->uio);
mutex_enter(&conn->lock);
- pdu->flags &= ~PDUF_INQUEUE;
- if (pdu->disp > PDUDISP_FREE)
+ pdisp = pdu->disp;
+ if (pdisp <= PDUDISP_FREE)
+ pdu->disp = PDUDISP_UNUSED;
+ else
pdu->flags &= ~PDUF_BUSY;
mutex_exit(&conn->lock);
- if (pdu->disp <= PDUDISP_FREE)
+ if (pdisp <= PDUDISP_FREE)
free_pdu(pdu);
mutex_enter(&conn->lock);
diff -r 56ce4e9974ce -r 937efa7e7874 sys/dev/iscsi/iscsi_utils.c
--- a/sys/dev/iscsi/iscsi_utils.c Sun Jun 05 13:45:56 2016 +0000
+++ b/sys/dev/iscsi/iscsi_utils.c Sun Jun 05 13:54:28 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iscsi_utils.c,v 1.18 2016/06/05 09:21:14 mlelstv Exp $ */
+/* $NetBSD: iscsi_utils.c,v 1.19 2016/06/05 13:54:28 mlelstv Exp $ */
/*-
* Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc.
@@ -268,16 +268,17 @@
free_ccb(ccb_t *ccb)
{
session_t *sess = ccb->session;
+ connection_t *conn = ccb->connection;
pdu_t *pdu;
- DEBC(ccb->connection, 15, (
+ DEBC(conn, 15, (
"free_ccb: ccb = %p, usecount = %d\n",
- ccb, ccb->connection->usecount-1));
+ ccb, conn->usecount-1));
KASSERT((ccb->flags & CCBF_THROTTLING) == 0);
KASSERT((ccb->flags & CCBF_WAITQUEUE) == 0);
- atomic_dec_uint(&ccb->connection->usecount);
+ atomic_dec_uint(&conn->usecount);
ccb->connection = NULL;
if (ccb->disp > CCBDISP_NOWAIT) {
@@ -296,6 +297,12 @@
/* free PDU waiting for ACK */
if ((pdu = ccb->pdu_waiting) != NULL) {
ccb->pdu_waiting = NULL;
+ mutex_enter(&conn->lock);
+ if ((pdu->flags & PDUF_INQUEUE) != 0) {
+ TAILQ_REMOVE(&conn->pdus_to_send, pdu, send_chain);
+ pdu->flags &= ~PDUF_INQUEUE;
+ }
+ mutex_exit(&conn->lock);
free_pdu(pdu);
}
Home |
Main Index |
Thread Index |
Old Index