Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Convert to new device buffer queue interface.



details:   https://anonhg.NetBSD.org/src/rev/9b7f48469a79
branches:  trunk
changeset: 534288:9b7f48469a79
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sat Jul 20 11:28:07 2002 +0000

description:
Convert to new device buffer queue interface.

diffstat:

 sys/dev/ld.c     |  14 ++++++--------
 sys/dev/ldvar.h  |   4 ++--
 sys/dev/md.c     |  22 ++++++++--------------
 sys/dev/vnd.c    |  11 +++++------
 sys/dev/vndvar.h |   4 ++--
 5 files changed, 23 insertions(+), 32 deletions(-)

diffs (209 lines):

diff -r 1cc84a587b20 -r 9b7f48469a79 sys/dev/ld.c
--- a/sys/dev/ld.c      Sat Jul 20 08:54:04 2002 +0000
+++ b/sys/dev/ld.c      Sat Jul 20 11:28:07 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld.c,v 1.13 2002/05/08 15:49:07 drochner Exp $ */
+/*     $NetBSD: ld.c,v 1.14 2002/07/20 11:28:07 hannken Exp $  */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.13 2002/05/08 15:49:07 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.14 2002/07/20 11:28:07 hannken Exp $");
 
 #include "rnd.h"
 
@@ -130,7 +130,7 @@
        /* Set the `shutdownhook'. */
        if (ld_sdh == NULL)
                ld_sdh = shutdownhook_establish(ldshutdown, NULL);
-       BUFQ_INIT(&sc->sc_bufq);
+       bufq_init(&sc->sc_bufq, BUFQ_FCFS);
 }
 
 int
@@ -194,8 +194,7 @@
 
        /* Kill off any queued buffers. */
        s = splbio();
-       while ((bp = BUFQ_FIRST(&sc->sc_bufq)) != NULL) {
-               BUFQ_REMOVE(&sc->sc_bufq, bp);
+       while ((bp = BUFQ_GET(&sc->sc_bufq)) != NULL) {
                bp->b_error = EIO;
                bp->b_flags |= B_ERROR;
                bp->b_resid = bp->b_bcount;
@@ -444,7 +443,7 @@
 
        s = splbio();
        if (sc->sc_queuecnt >= sc->sc_maxqueuecnt) {
-               BUFQ_INSERT_TAIL(&sc->sc_bufq, bp);
+               BUFQ_PUT(&sc->sc_bufq, bp);
                splx(s);
                return;
        }
@@ -547,8 +546,7 @@
        if (--sc->sc_queuecnt <= sc->sc_maxqueuecnt) {
                if ((sc->sc_flags & LDF_DRAIN) != 0)
                        wakeup(&sc->sc_queuecnt);
-               while ((bp = BUFQ_FIRST(&sc->sc_bufq)) != NULL) {
-                       BUFQ_REMOVE(&sc->sc_bufq, bp);
+               while ((bp = BUFQ_GET(&sc->sc_bufq)) != NULL) {
                        if (!ldstart(sc, bp))
                                break;
                }
diff -r 1cc84a587b20 -r 9b7f48469a79 sys/dev/ldvar.h
--- a/sys/dev/ldvar.h   Sat Jul 20 08:54:04 2002 +0000
+++ b/sys/dev/ldvar.h   Sat Jul 20 11:28:07 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ldvar.h,v 1.5 2001/06/10 10:48:42 ad Exp $     */
+/*     $NetBSD: ldvar.h,v 1.6 2002/07/20 11:28:07 hannken Exp $        */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
 struct ld_softc {
        struct  device sc_dv;
        struct  disk sc_dk;
-       struct  buf_queue sc_bufq;
+       struct  bufq_state sc_bufq;
 #if NRND > 0
        rndsource_element_t     sc_rnd_source;
 #endif
diff -r 1cc84a587b20 -r 9b7f48469a79 sys/dev/md.c
--- a/sys/dev/md.c      Sat Jul 20 08:54:04 2002 +0000
+++ b/sys/dev/md.c      Sat Jul 20 11:28:07 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.28 2002/01/13 19:28:07 tsutsui Exp $  */
+/*     $NetBSD: md.c,v 1.29 2002/07/20 11:28:08 hannken Exp $  */
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.28 2002/01/13 19:28:07 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.29 2002/07/20 11:28:08 hannken Exp $");
 
 #include "opt_md.h"
 
@@ -85,7 +85,7 @@
        struct device sc_dev;   /* REQUIRED first entry */
        struct disk sc_dkdev;   /* hook for generic disk handling */
        struct md_conf sc_md;
-       struct buf_queue sc_buflist;
+       struct bufq_state sc_buflist;
 };
 /* shorthand for fields in sc_md: */
 #define sc_addr sc_md.md_addr
@@ -147,7 +147,7 @@
 {
        struct md_softc *sc = (struct md_softc *)self;
 
-       BUFQ_INIT(&sc->sc_buflist);
+       bufq_init(&sc->sc_buflist, BUFQ_FCFS);
 
        /* XXX - Could accept aux info here to set the config. */
 #ifdef MEMORY_DISK_HOOKS
@@ -341,12 +341,9 @@
 #if MEMORY_DISK_SERVER
        case MD_UMEM_SERVER:
                /* Just add this job to the server's queue. */
-               BUFQ_INSERT_TAIL(&sc->sc_buflist, bp);
-               if (BUFQ_FIRST(&sc->sc_buflist) == bp) {
-                       /* server queue was empty. */
-                       wakeup((caddr_t)sc);
-                       /* see md_server_loop() */
-               }
+               BUFQ_PUT(&sc->sc_buflist, bp);
+               wakeup((caddr_t)sc);
+               /* see md_server_loop() */
                /* no biodone in this case */
                return;
 #endif /* MEMORY_DISK_SERVER */
@@ -505,15 +502,12 @@
 
        for (;;) {
                /* Wait for some work to arrive. */
-               while ((bp = BUFQ_FIRST(&sc->sc_buflist)) == NULL) {
+               while ((bp = BUFQ_GET(&sc->sc_buflist)) == NULL) {
                        error = tsleep((caddr_t)sc, md_sleep_pri, "md_idle", 0);
                        if (error)
                                return error;
                }
 
-               /* Unlink buf from head of list. */
-               BUFQ_REMOVE(&sc->sc_buflist, bp);
-
                /* Do the transfer to/from user space. */
                error = 0;
                bp->b_resid = bp->b_bcount;
diff -r 1cc84a587b20 -r 9b7f48469a79 sys/dev/vnd.c
--- a/sys/dev/vnd.c     Sat Jul 20 08:54:04 2002 +0000
+++ b/sys/dev/vnd.c     Sat Jul 20 11:28:07 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnd.c,v 1.80 2002/06/21 19:09:31 atatat Exp $  */
+/*     $NetBSD: vnd.c,v 1.81 2002/07/20 11:28:08 hannken Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.80 2002/06/21 19:09:31 atatat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.81 2002/07/20 11:28:08 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "fs_nfs.h"
@@ -202,7 +202,7 @@
        numvnd = num;
 
        for (i = 0; i < numvnd; i++)
-               BUFQ_INIT(&vnd_softc[i].sc_tab);
+               bufq_init(&vnd_softc[i].sc_tab, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
 }
 
 void
@@ -477,7 +477,7 @@
                }
                vnx->vx_pending++;
                bgetvp(vp, &nbp->vb_buf);
-               disksort_blkno(&vnd->sc_tab, &nbp->vb_buf);
+               BUFQ_PUT(&vnd->sc_tab, &nbp->vb_buf);
                vndstart(vnd);
                splx(s);
                bn += sz;
@@ -526,10 +526,9 @@
        vnd->sc_flags |= VNF_BUSY;
 
        while (vnd->sc_active < vnd->sc_maxactive) {
-               bp = BUFQ_FIRST(&vnd->sc_tab);
+               bp = BUFQ_GET(&vnd->sc_tab);
                if (bp == NULL)
                        break;
-               BUFQ_REMOVE(&vnd->sc_tab, bp);
                vnd->sc_active++;
 #ifdef DEBUG
                if (vnddebug & VDB_IO)
diff -r 1cc84a587b20 -r 9b7f48469a79 sys/dev/vndvar.h
--- a/sys/dev/vndvar.h  Sat Jul 20 08:54:04 2002 +0000
+++ b/sys/dev/vndvar.h  Sat Jul 20 11:28:07 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vndvar.h,v 1.7 2002/06/21 19:09:31 atatat Exp $        */
+/*     $NetBSD: vndvar.h,v 1.8 2002/07/20 11:28:08 hannken Exp $       */
 
 /*-     
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
        struct vnode    *sc_vp;         /* vnode */
        struct ucred    *sc_cred;       /* credentials */
        int              sc_maxactive;  /* max # of active requests */
-       struct buf_queue sc_tab;        /* transfer queue */
+       struct bufq_state sc_tab;       /* transfer queue */
        int              sc_active;     /* number of active transfers */
        char             sc_xname[8];   /* XXX external name */
        struct disk      sc_dkdev;      /* generic disk device info */



Home | Main Index | Thread Index | Old Index