Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/iscsi Fix locking for pdu flags here, in particular ...



details:   https://anonhg.NetBSD.org/src/rev/9e9692d2f812
branches:  trunk
changeset: 345689:9e9692d2f812
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jun 05 05:18:58 2016 +0000

description:
Fix locking for pdu flags here, in particular PDUF_INQUEUE.

diffstat:

 sys/dev/iscsi/iscsi_send.c  |  16 +++++++++++-----
 sys/dev/iscsi/iscsi_utils.c |  11 +++--------
 2 files changed, 14 insertions(+), 13 deletions(-)

diffs (74 lines):

diff -r db0da76b7766 -r 9e9692d2f812 sys/dev/iscsi/iscsi_send.c
--- a/sys/dev/iscsi/iscsi_send.c        Sun Jun 05 05:11:57 2016 +0000
+++ b/sys/dev/iscsi/iscsi_send.c        Sun Jun 05 05:18:58 2016 +0000
@@ -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 @@
                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 @@
                        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 @@
                                                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 -r db0da76b7766 -r 9e9692d2f812 sys/dev/iscsi/iscsi_utils.c
--- a/sys/dev/iscsi/iscsi_utils.c       Sun Jun 05 05:11:57 2016 +0000
+++ b/sys/dev/iscsi/iscsi_utils.c       Sun Jun 05 05:18:58 2016 +0000
@@ -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 @@
        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);



Home | Main Index | Thread Index | Old Index