Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode/dev Check reentry to prevent double use of...



details:   https://anonhg.NetBSD.org/src/rev/e8c45751d2d8
branches:  trunk
changeset: 769608:e8c45751d2d8
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Thu Sep 15 19:32:28 2011 +0000

description:
Check reentry to prevent double use of the aiocb structure

diffstat:

 sys/arch/usermode/dev/ld_thunkbus.c |  20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diffs (78 lines):

diff -r 968c55f197ad -r e8c45751d2d8 sys/arch/usermode/dev/ld_thunkbus.c
--- a/sys/arch/usermode/dev/ld_thunkbus.c       Thu Sep 15 19:29:23 2011 +0000
+++ b/sys/arch/usermode/dev/ld_thunkbus.c       Thu Sep 15 19:32:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.14 2011/09/13 10:40:26 reinoud Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.15 2011/09/15 19:32:28 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.14 2011/09/13 10:40:26 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.15 2011/09/15 19:32:28 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -68,6 +68,7 @@
        void            *sc_ih;
 
        struct ld_thunkbus_transfer sc_tt;
+       bool            busy;
 };
 
 CFATTACH_DECL_NEW(ld_thunkbus, sizeof(struct ld_thunkbus_softc),
@@ -128,6 +129,8 @@
        if (thunk_sigaction(SIGIO, &sa, NULL) == -1)
                panic("couldn't register SIGIO handler: %d", thunk_geterrno());
 
+       sc->busy = false;
+
        ldattach(ld);
 }
 
@@ -145,6 +148,7 @@
                if (tt) {
                        sc = tt->tt_sc;
                        spl_intr(IPL_BIO, softint_schedule, sc->sc_ih);
+                       // spl_intr(IPL_BIO, ld_thunkbus_complete, sc);
                        // softint_schedule(sc->sc_ih);
                }
        }
@@ -159,6 +163,9 @@
        struct ld_thunkbus_transfer *tt = &sc->sc_tt;
        struct buf *bp = tt->tt_bp;
 
+       if (!sc->busy)
+               panic("%s: but not busy?\n", __func__);
+
        if (thunk_aio_error(&tt->tt_aio) == 0 &&
            thunk_aio_return(&tt->tt_aio) != -1) {
                bp->b_resid = 0;
@@ -167,10 +174,11 @@
                bp->b_resid = bp->b_bcount;
        }
 
-//printf("\tfin\n");
+       dprintf_debug("\tfin\n");
        if (bp->b_error)
-               printf("error!\n");
+               dprintf_debug("error!\n");
 
+       sc->busy = false;
        lddone(&sc->sc_ld, bp);
 }
 
@@ -200,6 +208,10 @@
            (long long)bp->b_rawblkno,
            (long long)bp->b_bcount);
 #endif
+       if (sc->busy)
+               panic("%s: reentry", __func__);
+       sc->busy = true;
+
        if (bp->b_flags & B_READ)
                error = thunk_aio_read(&tt->tt_aio);
        else



Home | Main Index | Thread Index | Old Index