Source-Changes-HG archive

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

[src/trunk]: src/sys/dev support deferral of diskstart to a separate thread.



details:   https://anonhg.NetBSD.org/src/rev/c396f416b8f3
branches:  trunk
changeset: 812562:c396f416b8f3
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Mon Dec 21 12:33:12 2015 +0000

description:
support deferral of diskstart to a separate thread.

diffstat:

 sys/dev/dksubr.c |  60 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 sys/dev/dkvar.h  |   4 ++-
 2 files changed, 57 insertions(+), 7 deletions(-)

diffs (119 lines):

diff -r d8f3e1d97061 -r c396f416b8f3 sys/dev/dksubr.c
--- a/sys/dev/dksubr.c  Mon Dec 21 12:30:29 2015 +0000
+++ b/sys/dev/dksubr.c  Mon Dec 21 12:33:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.84 2015/12/21 12:30:29 mlelstv Exp $ */
+/* $NetBSD: dksubr.c,v 1.85 2015/12/21 12:33:12 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.84 2015/12/21 12:30:29 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.85 2015/12/21 12:33:12 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -276,8 +276,8 @@
        return bp->b_error;
 }
 
-void
-dk_strategy(struct dk_softc *dksc, struct buf *bp)
+static int
+dk_strategy1(struct dk_softc *dksc, struct buf *bp)
 {
        int error;
 
@@ -288,14 +288,26 @@
                DPRINTF_FOLLOW(("%s: not inited\n", __func__));
                bp->b_error  = ENXIO;
                biodone(bp);
-               return;
+               return 1;
        }
 
        error = dk_translate(dksc, bp);
        if (error >= 0) {
                biodone(bp);
+               return 1;
+       }
+
+       return 0;
+}
+
+void
+dk_strategy(struct dk_softc *dksc, struct buf *bp)
+{
+       int error;
+
+       error = dk_strategy1(dksc, bp);
+       if (error)
                return;
-       }
 
        /*
         * Queue buffer and start unit
@@ -303,6 +315,42 @@
        dk_start(dksc, bp);
 }
 
+int
+dk_strategy_defer(struct dk_softc *dksc, struct buf *bp)
+{
+       int error;
+
+       error = dk_strategy1(dksc, bp);
+       if (error)
+               return error;
+
+       /*
+        * Queue buffer only
+        */
+       mutex_enter(&dksc->sc_iolock);
+       bufq_put(dksc->sc_bufq, bp);
+       mutex_exit(&dksc->sc_iolock);
+
+       return 0;
+}
+
+int
+dk_strategy_pending(struct dk_softc *dksc)
+{
+       struct buf *bp;
+
+       if (!(dksc->sc_flags & DKF_INITED)) {
+               DPRINTF_FOLLOW(("%s: not inited\n", __func__));
+               return 0;
+       }
+
+       mutex_enter(&dksc->sc_iolock);
+       bp = bufq_peek(dksc->sc_bufq);
+       mutex_exit(&dksc->sc_iolock);
+
+       return bp != NULL;
+}
+
 void
 dk_start(struct dk_softc *dksc, struct buf *bp)
 {
diff -r d8f3e1d97061 -r c396f416b8f3 sys/dev/dkvar.h
--- a/sys/dev/dkvar.h   Mon Dec 21 12:30:29 2015 +0000
+++ b/sys/dev/dkvar.h   Mon Dec 21 12:33:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkvar.h,v 1.24 2015/08/28 17:41:49 mlelstv Exp $ */
+/* $NetBSD: dkvar.h,v 1.25 2015/12/21 12:33:12 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -92,6 +92,8 @@
 int    dk_close(struct dk_softc *, dev_t,
                 int, int, struct lwp *);
 void   dk_strategy(struct dk_softc *, struct buf *);
+int    dk_strategy_defer(struct dk_softc *, struct buf *);
+int    dk_strategy_pending(struct dk_softc *);
 int    dk_discard(struct dk_softc *, dev_t, off_t, off_t);
 void   dk_start(struct dk_softc *, struct buf *);
 void   dk_done(struct dk_softc *, struct buf *);



Home | Main Index | Thread Index | Old Index