Source-Changes-HG archive

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

[src/trunk]: src/sys - add simple functions to allocate/free a buffer for i/o.



details:   https://anonhg.NetBSD.org/src/rev/4f170bfc2306
branches:  trunk
changeset: 586853:4f170bfc2306
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Jan 04 10:13:05 2006 +0000

description:
- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.

diffstat:

 sys/arch/sparc/dev/fd.c          |  15 +++---------
 sys/dev/ata/ata_raid.c           |  16 ++++---------
 sys/dev/ata/wd.c                 |   9 +++----
 sys/dev/cgd.c                    |  15 ++++--------
 sys/dev/dkwedge/dk.c             |   8 +++---
 sys/dev/fss.c                    |  22 +++++-------------
 sys/dev/isa/fd.c                 |  16 ++++---------
 sys/dev/raidframe/rf_diskqueue.c |  20 ++++++----------
 sys/dev/scsipi/cd.c              |  21 ++++++------------
 sys/kern/kern_physio.c           |  15 +++---------
 sys/kern/vfs_bio.c               |  46 +++++++++++++++++++++++++++++++++++++--
 sys/miscfs/genfs/genfs_vnops.c   |  31 ++++++++------------------
 sys/sys/buf.h                    |  13 ++++------
 sys/ufs/ffs/ffs_snapshot.c       |  16 ++++---------
 sys/ufs/lfs/lfs_bio.c            |  12 +++------
 sys/ufs/lfs/lfs_segment.c        |  16 +++----------
 sys/ufs/lfs/lfs_vfsops.c         |  14 +++--------
 sys/uvm/uvm_pager.c              |   8 +++---
 sys/uvm/uvm_swap.c               |  11 +++------
 19 files changed, 135 insertions(+), 189 deletions(-)

diffs (truncated from 1001 to 300 lines):

diff -r df81772292e3 -r 4f170bfc2306 sys/arch/sparc/dev/fd.c
--- a/sys/arch/sparc/dev/fd.c   Wed Jan 04 04:56:41 2006 +0000
+++ b/sys/arch/sparc/dev/fd.c   Wed Jan 04 10:13:05 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.121 2005/12/11 12:19:05 christos Exp $        */
+/*     $NetBSD: fd.c,v 1.122 2006/01/04 10:13:05 yamt Exp $    */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -108,7 +108,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.121 2005/12/11 12:19:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.122 2006/01/04 10:13:05 yamt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -2138,20 +2138,16 @@
 int
 fdformat(dev_t dev, struct ne7_fd_formb *finfo, struct proc *p)
 {
-       int rv = 0, s;
+       int rv = 0;
        struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
        struct fd_type *type = fd->sc_type;
        struct buf *bp;
 
        /* set up a buffer header for fdstrategy() */
-       s = splbio();
-       bp = (struct buf *)pool_get(&bufpool, PR_NOWAIT);
-       splx(s);
+       bp = getiobuf_nowait();
        if (bp == NULL)
                return (ENOBUFS);
 
-       memset((void *)bp, 0, sizeof(struct buf));
-       BUF_INIT(bp);
        bp->b_flags = B_BUSY | B_PHYS | B_FORMAT;
        bp->b_proc = p;
        bp->b_dev = dev;
@@ -2197,9 +2193,6 @@
 
        /* ...and wait for it to complete */
        rv = biowait(bp);
-       s = splbio();
-       pool_put(&bufpool, bp);
-       splx(s);
        return (rv);
 }
 
diff -r df81772292e3 -r 4f170bfc2306 sys/dev/ata/ata_raid.c
--- a/sys/dev/ata/ata_raid.c    Wed Jan 04 04:56:41 2006 +0000
+++ b/sys/dev/ata/ata_raid.c    Wed Jan 04 10:13:05 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ata_raid.c,v 1.17 2005/12/11 12:21:14 christos Exp $   */
+/*     $NetBSD: ata_raid.c,v 1.18 2006/01/04 10:13:05 yamt Exp $       */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.17 2005/12/11 12:21:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.18 2006/01/04 10:13:05 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -286,13 +286,9 @@
     size_t size, int bflags)
 {
        struct buf *bp;
-       int error, s;
+       int error;
 
-       s = splbio();
-       bp = pool_get(&bufpool, PR_WAITOK);
-       splx(s);
-       BUF_INIT(bp);
-
+       bp = getiobuf();
        bp->b_vp = vp;
        bp->b_blkno = blkno;
        bp->b_bcount = bp->b_resid = size;
@@ -303,8 +299,6 @@
        VOP_STRATEGY(vp, bp);
        error = biowait(bp);
 
-       s = splbio();
-       pool_put(&bufpool, bp);
-       splx(s);
+       putiobuf(bp);
        return (error);
 }
diff -r df81772292e3 -r 4f170bfc2306 sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Wed Jan 04 04:56:41 2006 +0000
+++ b/sys/dev/ata/wd.c  Wed Jan 04 10:13:05 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.315 2005/12/26 10:36:47 yamt Exp $ */
+/*     $NetBSD: wd.c,v 1.316 2006/01/04 10:13:05 yamt Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.315 2005/12/26 10:36:47 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.316 2006/01/04 10:13:05 yamt Exp $");
 
 #ifndef ATADEBUG
 #define ATADEBUG
@@ -648,7 +648,7 @@
        obp->b_flags |= (bp->b_flags & (B_EINTR|B_ERROR));
        obp->b_error = bp->b_error;
        obp->b_resid = bp->b_resid;
-       pool_put(&bufpool, bp);
+       putiobuf(bp);
        biodone(obp);
        sc->openings++;
        /* wddone() will call wdstart() */
@@ -673,7 +673,7 @@
                struct buf *nbp;
 
                /* already at splbio */
-               nbp = pool_get(&bufpool, PR_NOWAIT);
+               nbp = getiobuf_nowait();
                if (__predict_false(nbp == NULL)) {
                        /* No memory -- fail the iop. */
                        bp->b_error = ENOMEM;
@@ -684,7 +684,6 @@
                        return;
                }
 
-               BUF_INIT(nbp);
                nbp->b_error = 0;
                nbp->b_proc = bp->b_proc;
                nbp->b_vp = NULLVP;
diff -r df81772292e3 -r 4f170bfc2306 sys/dev/cgd.c
--- a/sys/dev/cgd.c     Wed Jan 04 04:56:41 2006 +0000
+++ b/sys/dev/cgd.c     Wed Jan 04 10:13:05 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.32 2005/12/11 12:20:53 christos Exp $ */
+/* $NetBSD: cgd.c,v 1.33 2006/01/04 10:13:05 yamt Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.32 2005/12/11 12:20:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.33 2006/01/04 10:13:05 yamt Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -308,9 +308,7 @@
         * we can fail quickly if they are unavailable.
         */
 
-       s = splbio();
-       nbp = pool_get(&bufpool, PR_NOWAIT);
-       splx(s);
+       nbp = getiobuf_nowait();
        if (nbp == NULL) {
                disk_unbusy(&dksc->sc_dkdev, 0, (bp->b_flags & B_READ));
                return -1;
@@ -325,9 +323,7 @@
        if ((bp->b_flags & B_READ) == 0) {
                newaddr = cgd_getdata(dksc, bp->b_bcount);
                if (!newaddr) {
-                       s = splbio();
-                       pool_put(&bufpool, nbp);
-                       splx(s);
+                       putiobuf(nbp);
                        disk_unbusy(&dksc->sc_dkdev, 0, (bp->b_flags & B_READ));
                        return -1;
                }
@@ -335,7 +331,6 @@
                    DEV_BSIZE, CGD_CIPHER_ENCRYPT);
        }
 
-       BUF_INIT(nbp);
        nbp->b_data = newaddr;
        nbp->b_flags = bp->b_flags | B_CALL;
        nbp->b_iodone = cgdiodone;
@@ -391,7 +386,7 @@
        if (nbp->b_data != obp->b_data)
                cgd_putdata(dksc, nbp->b_data);
 
-       pool_put(&bufpool, nbp);
+       putiobuf(nbp);
 
        /* Request is complete for whatever reason */
        obp->b_resid = 0;
diff -r df81772292e3 -r 4f170bfc2306 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Wed Jan 04 04:56:41 2006 +0000
+++ b/sys/dev/dkwedge/dk.c      Wed Jan 04 10:13:05 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.10 2005/12/11 12:21:20 christos Exp $ */
+/*     $NetBSD: dk.c,v 1.11 2006/01/04 10:13:05 yamt Exp $     */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.10 2005/12/11 12:21:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.11 2006/01/04 10:13:05 yamt Exp $");
 
 #include "opt_dkwedge.h"
 
@@ -1036,7 +1036,7 @@
                /* Instrumentation. */
                disk_busy(&sc->sc_dk);
 
-               nbp = pool_get(&bufpool, PR_NOWAIT);
+               nbp = getiobuf_nowait();
                if (nbp == NULL) {
                        /*
                         * No resources to run this request; leave the
@@ -1085,7 +1085,7 @@
                obp->b_error = bp->b_error;
        }
        obp->b_resid = bp->b_resid;
-       pool_put(&bufpool, bp);
+       putiobuf(bp);
 
        if (sc->sc_iopend-- == 1 && (sc->sc_flags & DK_F_WAIT_DRAIN) != 0) {
                sc->sc_flags &= ~DK_F_WAIT_DRAIN;
diff -r df81772292e3 -r 4f170bfc2306 sys/dev/fss.c
--- a/sys/dev/fss.c     Wed Jan 04 04:56:41 2006 +0000
+++ b/sys/dev/fss.c     Wed Jan 04 10:13:05 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fss.c,v 1.18 2005/12/11 12:20:53 christos Exp $        */
+/*     $NetBSD: fss.c,v 1.19 2006/01/04 10:13:05 yamt Exp $    */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.18 2005/12/11 12:20:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.19 2006/01/04 10:13:05 yamt Exp $");
 
 #include "fss.h"
 
@@ -839,9 +839,7 @@
 
        FSS_UNLOCK(scp->fc_softc, s);
 
-       s = splbio();
-       pool_put(&bufpool, bp);
-       splx(s);
+       putiobuf(bp);
 }
 
 /*
@@ -908,11 +906,7 @@
                if (len > MAXPHYS)
                        len = MAXPHYS;
 
-               s = splbio();
-               bp = pool_get(&bufpool, PR_WAITOK);
-               splx(s);
-
-               BUF_INIT(bp);
+               bp = getiobuf();
                bp->b_flags = B_READ|B_CALL;
                bp->b_bcount = len;
                bp->b_bufsize = bp->b_bcount;
@@ -1036,9 +1030,7 @@
 
        scl = sc->sc_cache+sc->sc_cache_size;
 
-       s = splbio();
-       nbp = pool_get(&bufpool, PR_WAITOK);
-       splx(s);
+       nbp = getiobuf();
 
        nfreed = nio = 1;               /* Dont sleep the first time */
 
@@ -1055,9 +1047,7 @@
 
                        FSS_UNLOCK(sc, s);
 
-                       s = splbio();
-                       pool_put(&bufpool, nbp);
-                       splx(s);
+                       putiobuf(nbp);
 #ifdef FSS_STATISTICS
                        if ((sc->sc_flags & FSS_PERSISTENT) == 0) {
                                printf("fss%d: cow called %" PRId64 " times,"
diff -r df81772292e3 -r 4f170bfc2306 sys/dev/isa/fd.c
--- a/sys/dev/isa/fd.c  Wed Jan 04 04:56:41 2006 +0000
+++ b/sys/dev/isa/fd.c  Wed Jan 04 10:13:05 2006 +0000
@@ -1,4 +1,4 @@



Home | Main Index | Thread Index | Old Index