Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/ab8654df65b7
branches:  trunk
changeset: 534177:ab8654df65b7
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Jul 19 16:26:01 2002 +0000

description:
Convert to new device buffer queue interface.

diffstat:

 sys/ufs/mfs/mfs_vfsops.c |  18 ++++++++++--------
 sys/ufs/mfs/mfs_vnops.c  |  18 ++++++++----------
 sys/ufs/mfs/mfsnode.h    |   5 +++--
 sys/uvm/uvm_swap.c       |  15 +++++++--------
 4 files changed, 28 insertions(+), 28 deletions(-)

diffs (211 lines):

diff -r c30472ec6452 -r ab8654df65b7 sys/ufs/mfs/mfs_vfsops.c
--- a/sys/ufs/mfs/mfs_vfsops.c  Fri Jul 19 16:13:40 2002 +0000
+++ b/sys/ufs/mfs/mfs_vfsops.c  Fri Jul 19 16:26:01 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mfs_vfsops.c,v 1.38 2002/03/04 02:25:24 simonb Exp $   */
+/*     $NetBSD: mfs_vfsops.c,v 1.39 2002/07/19 16:26:01 hannken Exp $  */
 
 /*
  * Copyright (c) 1989, 1990, 1993, 1994
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.38 2002/03/04 02:25:24 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.39 2002/07/19 16:26:01 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -169,7 +169,8 @@
        mfsp->mfs_size = mfs_rootsize;
        mfsp->mfs_vnode = rootvp;
        mfsp->mfs_proc = NULL;          /* indicate kernel space */
-       BUFQ_INIT(&mfsp->mfs_buflist);
+       mfsp->mfs_shutdown = 0;
+       bufq_init(&mfsp->mfs_buflist, BUFQ_FCFS);
        if ((error = ffs_mountfs(rootvp, mp, p)) != 0) {
                mp->mnt_op->vfs_refcount--;
                vfs_unbusy(mp);
@@ -281,9 +282,10 @@
        mfsp->mfs_size = args.size;
        mfsp->mfs_vnode = devvp;
        mfsp->mfs_proc = p;
-       BUFQ_INIT(&mfsp->mfs_buflist);
+       mfsp->mfs_shutdown = 0;
+       bufq_init(&mfsp->mfs_buflist, BUFQ_FCFS);
        if ((error = ffs_mountfs(devvp, mp, p)) != 0) {
-               BUFQ_FIRST(&mfsp->mfs_buflist) = (struct buf *) -1;
+               mfsp->mfs_shutdown = 1;
                vrele(devvp);
                return (error);
        }
@@ -322,9 +324,8 @@
        int sleepreturn = 0;
 
        base = mfsp->mfs_baseoff;
-       while (BUFQ_FIRST(&mfsp->mfs_buflist) != (struct buf *) -1) {
-               while ((bp = BUFQ_FIRST(&mfsp->mfs_buflist)) != NULL) {
-                       BUFQ_REMOVE(&mfsp->mfs_buflist, bp);
+       while (mfsp->mfs_shutdown != 1) {
+               while ((bp = BUFQ_GET(&mfsp->mfs_buflist)) != NULL) {
                        mfs_doio(bp, base);
                        wakeup((caddr_t)bp);
                }
@@ -351,6 +352,7 @@
 
                sleepreturn = tsleep(vp, mfs_pri, "mfsidl", 0);
        }
+       KASSERT(BUFQ_PEEK(&mfsp->mfs_buflist) == NULL);
        return (sleepreturn);
 }
 
diff -r c30472ec6452 -r ab8654df65b7 sys/ufs/mfs/mfs_vnops.c
--- a/sys/ufs/mfs/mfs_vnops.c   Fri Jul 19 16:13:40 2002 +0000
+++ b/sys/ufs/mfs/mfs_vnops.c   Fri Jul 19 16:26:01 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mfs_vnops.c,v 1.29 2001/12/06 04:27:43 chs Exp $       */
+/*     $NetBSD: mfs_vnops.c,v 1.30 2002/07/19 16:26:01 hannken Exp $   */
 
 /*
  * Copyright (c) 1989, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mfs_vnops.c,v 1.29 2001/12/06 04:27:43 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfs_vnops.c,v 1.30 2002/07/19 16:26:01 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -176,7 +176,7 @@
                bp->b_resid = 0;
                biodone(bp);
        } else {
-               BUFQ_INSERT_TAIL(&mfsp->mfs_buflist, bp);
+               BUFQ_PUT(&mfsp->mfs_buflist, bp);
                wakeup((caddr_t)vp);
        }
        return (0);
@@ -250,8 +250,7 @@
        /*
         * Finish any pending I/O requests.
         */
-       while ((bp = BUFQ_FIRST(&mfsp->mfs_buflist)) != NULL) {
-               BUFQ_REMOVE(&mfsp->mfs_buflist, bp);
+       while ((bp = BUFQ_GET(&mfsp->mfs_buflist)) != NULL) {
                mfs_doio(bp, mfsp->mfs_baseoff);
                wakeup((caddr_t)bp);
        }
@@ -268,12 +267,12 @@
         */
        if (vp->v_usecount > 1)
                printf("mfs_close: ref count %d > 1\n", vp->v_usecount);
-       if (vp->v_usecount > 1 || BUFQ_FIRST(&mfsp->mfs_buflist) != NULL)
+       if (vp->v_usecount > 1 || BUFQ_PEEK(&mfsp->mfs_buflist) != NULL)
                panic("mfs_close");
        /*
         * Send a request to the filesystem server to exit.
         */
-       BUFQ_FIRST(&mfsp->mfs_buflist) = (struct buf *) -1;
+       mfsp->mfs_shutdown = 1;
        wakeup((caddr_t)vp);
        return (0);
 }
@@ -293,10 +292,9 @@
        struct vnode *vp = ap->a_vp;
        struct mfsnode *mfsp = VTOMFS(vp);
 
-       if (BUFQ_FIRST(&mfsp->mfs_buflist) != NULL &&
-           BUFQ_FIRST(&mfsp->mfs_buflist) != (struct buf *) -1)
+       if (BUFQ_PEEK(&mfsp->mfs_buflist) != NULL)
                panic("mfs_inactive: not inactive (mfs_buflist %p)",
-                       BUFQ_FIRST(&mfsp->mfs_buflist));
+                       BUFQ_PEEK(&mfsp->mfs_buflist));
        VOP_UNLOCK(vp, 0);
        return (0);
 }
diff -r c30472ec6452 -r ab8654df65b7 sys/ufs/mfs/mfsnode.h
--- a/sys/ufs/mfs/mfsnode.h     Fri Jul 19 16:13:40 2002 +0000
+++ b/sys/ufs/mfs/mfsnode.h     Fri Jul 19 16:26:01 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mfsnode.h,v 1.11 2001/12/06 04:27:43 chs Exp $ */
+/*     $NetBSD: mfsnode.h,v 1.12 2002/07/19 16:26:01 hannken Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,8 @@
        caddr_t mfs_baseoff;            /* base of file system in memory */
        long    mfs_size;               /* size of memory file system */
        struct  proc *mfs_proc;         /* supporting process */
-       struct  buf_queue mfs_buflist;  /* list of I/O requests */
+       struct  bufq_state mfs_buflist; /* list of I/O requests */
+       int     mfs_shutdown;           /* shutdown this mfsnode */
 };
 
 /*
diff -r c30472ec6452 -r ab8654df65b7 sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c        Fri Jul 19 16:13:40 2002 +0000
+++ b/sys/uvm/uvm_swap.c        Fri Jul 19 16:26:01 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_swap.c,v 1.64 2002/05/09 21:43:44 fredette Exp $   */
+/*     $NetBSD: uvm_swap.c,v 1.65 2002/07/19 16:27:02 hannken Exp $    */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.64 2002/05/09 21:43:44 fredette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.65 2002/07/19 16:27:02 hannken Exp $");
 
 #include "fs_nfs.h"
 #include "opt_uvmhist.h"
@@ -140,7 +140,7 @@
 
        int                     swd_bsize;      /* blocksize (bytes) */
        int                     swd_maxactive;  /* max active i/o reqs */
-       struct buf_queue        swd_tab;        /* buffer list */
+       struct bufq_state       swd_tab;        /* buffer list */
        int                     swd_active;     /* number of active buffers */
 };
 
@@ -617,7 +617,7 @@
                sdp->swd_flags = SWF_FAKE;      /* placeholder only */
                sdp->swd_vp = vp;
                sdp->swd_dev = (vp->v_type == VBLK) ? vp->v_rdev : NODEV;
-               BUFQ_INIT(&sdp->swd_tab);
+               bufq_init(&sdp->swd_tab, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
 
                swaplist_insert(sdp, spp, priority);
                simple_unlock(&uvm.swap_data_lock);
@@ -1296,7 +1296,7 @@
                vnx->vx_pending++;
 
                /* sort it in and start I/O if we are not over our limit */
-               disksort_blkno(&sdp->swd_tab, &nbp->vb_buf);
+               BUFQ_PUT(&sdp->swd_tab, &nbp->vb_buf);
                sw_reg_start(sdp);
                splx(s);
 
@@ -1325,7 +1325,7 @@
 /*
  * sw_reg_start: start an I/O request on the requested swapdev
  *
- * => reqs are sorted by disksort (above)
+ * => reqs are sorted by b_rawblkno (above)
  */
 static void
 sw_reg_start(sdp)
@@ -1341,10 +1341,9 @@
        sdp->swd_flags |= SWF_BUSY;
 
        while (sdp->swd_active < sdp->swd_maxactive) {
-               bp = BUFQ_FIRST(&sdp->swd_tab);
+               bp = BUFQ_GET(&sdp->swd_tab);
                if (bp == NULL)
                        break;
-               BUFQ_REMOVE(&sdp->swd_tab, bp);
                sdp->swd_active++;
 
                UVMHIST_LOG(pdhist,



Home | Main Index | Thread Index | Old Index