- add simple functions to allocate/free a buffer for i/o.

- make bufpool static.
This commit is contained in:
yamt 2006-01-04 10:13:05 +00:00
parent 35f400bfd9
commit 690d424f28
19 changed files with 135 additions and 189 deletions

View File

@ -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 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct lwp *l)
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 @@ fdformat(dev_t dev, struct ne7_fd_formb *finfo, struct proc *p)
/* ...and wait for it to complete */
rv = biowait(bp);
s = splbio();
pool_put(&bufpool, bp);
splx(s);
return (rv);
}

View File

@ -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 @@ ata_raid_config_block_rw(struct vnode *vp, daddr_t blkno, void *tbuf,
size_t size, int bflags)
{
struct buf *bp;
int error, s;
s = splbio();
bp = pool_get(&bufpool, PR_WAITOK);
splx(s);
BUF_INIT(bp);
int error;
bp = getiobuf();
bp->b_vp = vp;
bp->b_blkno = blkno;
bp->b_bcount = bp->b_resid = size;
@ -303,8 +299,6 @@ ata_raid_config_block_rw(struct vnode *vp, daddr_t blkno, void *tbuf,
VOP_STRATEGY(vp, bp);
error = biowait(bp);
s = splbio();
pool_put(&bufpool, bp);
splx(s);
putiobuf(bp);
return (error);
}

View File

@ -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 @@ wd_split_mod15_write(struct buf *bp)
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 @@ __wdstart(struct wd_softc *wd, struct buf *bp)
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 @@ __wdstart(struct wd_softc *wd, struct buf *bp)
return;
}
BUF_INIT(nbp);
nbp->b_error = 0;
nbp->b_proc = bp->b_proc;
nbp->b_vp = NULLVP;

View File

@ -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 @@ cgdstart(struct dk_softc *dksc, struct buf *bp)
* 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 @@ cgdstart(struct dk_softc *dksc, struct buf *bp)
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 @@ cgdstart(struct dk_softc *dksc, struct buf *bp)
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 @@ cgdiodone(struct buf *nbp)
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;

View File

@ -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 @@ dkstart(struct dkwedge_softc *sc)
/* 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 @@ dkiodone(struct buf *bp)
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;

View File

@ -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_cluster_iodone(struct buf *bp)
FSS_UNLOCK(scp->fc_softc, s);
s = splbio();
pool_put(&bufpool, bp);
splx(s);
putiobuf(bp);
}
/*
@ -908,11 +906,7 @@ restart:
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 @@ fss_bs_thread(void *arg)
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_bs_thread(void *arg)
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,"

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.62 2005/12/24 20:27:41 perry Exp $ */
/* $NetBSD: fd.c,v 1.63 2006/01/04 10:13:05 yamt Exp $ */
/*-
* Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.62 2005/12/24 20:27:41 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.63 2006/01/04 10:13:05 yamt Exp $");
#include "rnd.h"
#include "opt_ddb.h"
@ -1522,20 +1522,16 @@ fdformat(dev, finfo, l)
struct ne7_fd_formb *finfo;
struct lwp *l;
{
int rv = 0, s;
int rv = 0;
struct fd_softc *fd = device_lookup(&fd_cd, 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 = l->l_proc;
bp->b_dev = dev;
@ -1560,9 +1556,7 @@ fdformat(dev, finfo, l)
/* ...and wait for it to complete */
rv = biowait(bp);
s = splbio();
pool_put(&bufpool, bp);
splx(s);
putiobuf(bp);
return rv;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_diskqueue.c,v 1.42 2005/12/11 12:23:37 christos Exp $ */
/* $NetBSD: rf_diskqueue.c,v 1.43 2006/01/04 10:13:05 yamt Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -66,7 +66,7 @@
****************************************************************************/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.42 2005/12/11 12:23:37 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.43 2006/01/04 10:13:05 yamt Exp $");
#include <dev/raidframe/raidframevar.h>
@ -449,24 +449,23 @@ rf_CreateDiskQueueData(RF_IoType_t typ, RF_SectorNum_t ssect,
int waitflag)
{
RF_DiskQueueData_t *p;
int s;
p = pool_get(&rf_pools.dqd, waitflag);
if (p == NULL)
return (NULL);
memset(p, 0, sizeof(RF_DiskQueueData_t));
/* Need to be at splbio to access bufpool! */
s = splbio();
p->bp = pool_get(&bufpool, waitflag);
splx(s);
if (waitflag == PR_WAITOK) {
p->bp = getiobuf();
} else {
p->bp = getiobuf_nowait();
}
if (p->bp == NULL) {
/* no memory for the buffer!?!? */
pool_put(&rf_pools.dqd, p);
return (NULL);
}
memset(p->bp, 0, sizeof(struct buf));
p->sectorOffset = ssect + rf_protectedSectors;
p->numSector = nsect;
p->type = typ;
@ -487,10 +486,7 @@ rf_CreateDiskQueueData(RF_IoType_t typ, RF_SectorNum_t ssect,
void
rf_FreeDiskQueueData(RF_DiskQueueData_t *p)
{
int s;
s = splbio();
pool_put(&bufpool, p->bp);
splx(s);
putiobuf(p->bp);
pool_put(&rf_pools.dqd, p);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.234 2005/12/21 13:11:27 reinoud Exp $ */
/* $NetBSD: cd.c,v 1.235 2006/01/04 10:13:05 yamt Exp $ */
/*-
* Copyright (c) 1998, 2001, 2003, 2004, 2005 The NetBSD Foundation, Inc.
@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.234 2005/12/21 13:11:27 reinoud Exp $");
__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.235 2006/01/04 10:13:05 yamt Exp $");
#include "rnd.h"
@ -649,9 +649,7 @@ cdstrategy(struct buf *bp)
count = roundup(count, cd->params.blksize);
blkno = ((blkno * lp->d_secsize) / cd->params.blksize);
s = splbio();
nbp = pool_get(&bufpool, PR_NOWAIT);
splx(s);
nbp = getiobuf_nowait();
if (!nbp) {
/* No memory -- fail the iop. */
bp->b_error = ENOMEM;
@ -660,15 +658,12 @@ cdstrategy(struct buf *bp)
bounce = malloc(count, M_DEVBUF, M_NOWAIT);
if (!bounce) {
/* No memory -- fail the iop. */
s = splbio();
pool_put(&bufpool, nbp);
splx(s);
putiobuf(nbp);
bp->b_error = ENOMEM;
goto bad;
}
/* Set up the IOP to the bounce buffer. */
BUF_INIT(nbp);
nbp->b_error = 0;
nbp->b_proc = bp->b_proc;
nbp->b_vp = NULLVP;
@ -930,20 +925,17 @@ cdbounce(struct buf *bp)
memcpy(bp->b_data+obp->b_rawblkno, obp->b_data,
obp->b_bcount);
s = splbio();
/* We need to alloc a new buf. */
nbp = pool_get(&bufpool, PR_NOWAIT);
nbp = getiobuf_nowait();
if (!nbp) {
splx(s);
/* No buf available. */
bp->b_flags |= B_ERROR;
bp->b_error = ENOMEM;
bp->b_resid = bp->b_bcount;
goto done;
}
/* Set up the IOP to the bounce buffer. */
BUF_INIT(nbp);
nbp->b_error = 0;
nbp->b_proc = bp->b_proc;
nbp->b_vp = NULLVP;
@ -961,6 +953,7 @@ cdbounce(struct buf *bp)
/* Put ptr to orig buf in b_private and use new buf */
nbp->b_private = obp;
s = splbio();
/*
* Place it in the queue of disk activities for this
* disk.

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_physio.c,v 1.70 2005/12/17 05:26:41 yamt Exp $ */
/* $NetBSD: kern_physio.c,v 1.71 2006/01/04 10:13:05 yamt Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1993
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.70 2005/12/17 05:26:41 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.71 2006/01/04 10:13:05 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -117,12 +117,8 @@ static struct buf *
getphysbuf(void)
{
struct buf *bp;
int s;
s = splbio();
bp = pool_get(&bufpool, PR_WAITOK);
splx(s);
BUF_INIT(bp);
bp = getiobuf();
bp->b_error = 0;
bp->b_flags = B_BUSY;
return(bp);
@ -134,7 +130,6 @@ getphysbuf(void)
static void
putphysbuf(struct buf *bp)
{
int s;
if ((bp->b_flags & B_DONTFREE) != 0) {
return;
@ -142,9 +137,7 @@ putphysbuf(struct buf *bp)
if (__predict_false(bp->b_flags & B_WANTED))
panic("putphysbuf: private buf B_WANTED");
s = splbio();
pool_put(&bufpool, bp);
splx(s);
putiobuf(bp);
}
static void

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_bio.c,v 1.148 2005/12/24 19:12:23 perry Exp $ */
/* $NetBSD: vfs_bio.c,v 1.149 2006/01/04 10:13:05 yamt Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@ -81,7 +81,7 @@
#include "opt_softdep.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.148 2005/12/24 19:12:23 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.149 2006/01/04 10:13:05 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -182,8 +182,9 @@ struct simplelock bqueue_slock = SIMPLELOCK_INITIALIZER;
/*
* Buffer pool for I/O buffers.
* Access to this pool must be protected with splbio().
*/
struct pool bufpool;
static struct pool bufpool;
/* XXX - somewhat gross.. */
#if MAXBSIZE == 0x2000
@ -1731,3 +1732,42 @@ vfs_bufstats(void)
}
}
#endif /* DEBUG */
static struct buf *
getiobuf1(int prflags)
{
struct buf *bp;
int s;
s = splbio();
bp = pool_get(&bufpool, prflags);
splx(s);
if (bp != NULL) {
BUF_INIT(bp);
}
return bp;
}
struct buf *
getiobuf(void)
{
return getiobuf1(PR_WAITOK);
}
struct buf *
getiobuf_nowait(void)
{
return getiobuf1(PR_NOWAIT);
}
void
putiobuf(struct buf *bp)
{
int s;
s = splbio();
pool_put(&bufpool, bp);
splx(s);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: genfs_vnops.c,v 1.118 2005/12/24 20:45:09 perry Exp $ */
/* $NetBSD: genfs_vnops.c,v 1.119 2006/01/04 10:13:06 yamt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.118 2005/12/24 20:45:09 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.119 2006/01/04 10:13:06 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_nfsserver.h"
@ -665,10 +665,7 @@ genfs_getpages(void *v)
kva = uvm_pagermapin(pgs, npages,
UVMPAGER_MAPIN_READ | UVMPAGER_MAPIN_WAITOK);
s = splbio();
mbp = pool_get(&bufpool, PR_WAITOK);
splx(s);
BUF_INIT(mbp);
mbp = getiobuf();
mbp->b_bufsize = totalbytes;
mbp->b_data = (void *)kva;
mbp->b_resid = mbp->b_bcount = bytes;
@ -802,10 +799,7 @@ genfs_getpages(void *v)
if (offset == startoffset && iobytes == bytes) {
bp = mbp;
} else {
s = splbio();
bp = pool_get(&bufpool, PR_WAITOK);
splx(s);
BUF_INIT(bp);
bp = getiobuf();
bp->b_data = (char *)kva + offset - startoffset;
bp->b_resid = bp->b_bcount = iobytes;
bp->b_flags = B_BUSY|B_READ|B_CALL|B_ASYNC;
@ -856,9 +850,7 @@ loopdone:
if (bp != NULL) {
error = biowait(mbp);
}
s = splbio();
pool_put(&bufpool, mbp);
splx(s);
putiobuf(mbp);
uvm_pagermapout(kva, npages);
raoffset = startoffset + totalbytes;
@ -1474,11 +1466,10 @@ genfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
simple_lock(&global_v_numoutput_slock);
vp->v_numoutput += 2;
simple_unlock(&global_v_numoutput_slock);
mbp = pool_get(&bufpool, PR_WAITOK);
BUF_INIT(mbp);
splx(s);
mbp = getiobuf();
UVMHIST_LOG(ubchist, "vp %p mbp %p num now %d bytes 0x%x",
vp, mbp, vp->v_numoutput, bytes);
splx(s);
mbp->b_bufsize = npages << PAGE_SHIFT;
mbp->b_data = (void *)kva;
mbp->b_resid = mbp->b_bcount = bytes;
@ -1512,11 +1503,10 @@ genfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
} else {
s = splbio();
V_INCR_NUMOUTPUT(vp);
bp = pool_get(&bufpool, PR_WAITOK);
splx(s);
bp = getiobuf();
UVMHIST_LOG(ubchist, "vp %p bp %p num now %d",
vp, bp, vp->v_numoutput, 0);
splx(s);
BUF_INIT(bp);
bp->b_data = (char *)kva +
(vaddr_t)(offset - pg->offset);
bp->b_resid = bp->b_bcount = iobytes;
@ -1729,10 +1719,9 @@ genfs_compat_gop_write(struct vnode *vp, struct vm_page **pgs, int npages,
s = splbio();
V_INCR_NUMOUTPUT(vp);
bp = pool_get(&bufpool, PR_WAITOK);
splx(s);
BUF_INIT(bp);
bp = getiobuf();
bp->b_flags = B_BUSY | B_WRITE | B_AGE;
bp->b_vp = vp;
bp->b_lblkno = offset >> vp->v_mount->mnt_fs_bshift;

View File

@ -1,4 +1,4 @@
/* $NetBSD: buf.h,v 1.84 2005/12/11 12:25:20 christos Exp $ */
/* $NetBSD: buf.h,v 1.85 2006/01/04 10:13:06 yamt Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -263,12 +263,6 @@ do { \
extern struct bio_ops bioops;
extern u_int nbuf; /* The number of buffer headers */
/*
* Pool of I/O buffers. Access to this pool must be protected with
* splbio().
*/
extern struct pool bufpool;
__BEGIN_DECLS
void allocbuf(struct buf *, int, int);
void bawrite(struct buf *);
@ -304,7 +298,10 @@ int buf_setvalimit(vsize_t);
#ifdef DDB
void vfs_buf_print(struct buf *, int, void (*)(const char *, ...));
#endif
struct buf *getiobuf(void);
struct buf *getiobuf_nowait(void);
void putiobuf(struct buf *);
__END_DECLS
#endif
#endif /* _KERNEL */
#endif /* !_SYS_BUF_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_snapshot.c,v 1.23 2005/12/11 12:25:25 christos Exp $ */
/* $NetBSD: ffs_snapshot.c,v 1.24 2006/01/04 10:13:06 yamt Exp $ */
/*
* Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.23 2005/12/11 12:25:25 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.24 2006/01/04 10:13:06 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -1984,16 +1984,12 @@ retry:
static int
readfsblk(struct vnode *vp, caddr_t data, ufs2_daddr_t lbn)
{
int s, error;
int error;
struct inode *ip = VTOI(vp);
struct fs *fs = ip->i_fs;
struct buf *nbp;
s = splbio();
nbp = pool_get(&bufpool, PR_WAITOK);
splx(s);
BUF_INIT(nbp);
nbp = getiobuf();
nbp->b_flags = B_READ;
nbp->b_bcount = nbp->b_bufsize = fs->fs_bsize;
nbp->b_error = 0;
@ -2007,9 +2003,7 @@ readfsblk(struct vnode *vp, caddr_t data, ufs2_daddr_t lbn)
error = biowait(nbp);
s = splbio();
pool_put(&bufpool, nbp);
splx(s);
putiobuf(nbp);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_bio.c,v 1.87 2005/12/11 12:25:26 christos Exp $ */
/* $NetBSD: lfs_bio.c,v 1.88 2006/01/04 10:13:06 yamt Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.87 2005/12/11 12:25:26 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.88 2006/01/04 10:13:06 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -744,11 +744,7 @@ lfs_newbuf(struct lfs *fs, struct vnode *vp, daddr_t daddr, size_t size, int typ
ASSERT_MAYBE_SEGLOCK(fs);
nbytes = roundup(size, fsbtob(fs, 1));
s = splbio();
bp = pool_get(&bufpool, PR_WAITOK);
splx(s);
memset(bp, 0, sizeof(struct buf));
BUF_INIT(bp);
bp = getiobuf();
if (nbytes) {
bp->b_data = lfs_malloc(fs, nbytes, type);
/* memset(bp->b_data, 0, nbytes); */
@ -788,8 +784,8 @@ lfs_freebuf(struct lfs *fs, struct buf *bp)
lfs_free(fs, bp->b_data, LFS_NB_UNKNOWN);
bp->b_data = NULL;
}
pool_put(&bufpool, bp);
splx(s);
putiobuf(bp);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_segment.c,v 1.168 2005/12/11 12:25:26 christos Exp $ */
/* $NetBSD: lfs_segment.c,v 1.169 2006/01/04 10:13:06 yamt Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.168 2005/12/11 12:25:26 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.169 2006/01/04 10:13:06 yamt Exp $");
#ifdef DEBUG
# define vndebug(vp, str) do { \
@ -1703,7 +1703,6 @@ lfs_newclusterbuf(struct lfs *fs, struct vnode *vp, daddr_t addr, int n)
{
struct lfs_cluster *cl;
struct buf **bpp, *bp;
int s;
ASSERT_SEGLOCK(fs);
cl = (struct lfs_cluster *)pool_get(&fs->lfs_clpool, PR_WAITOK);
@ -1722,12 +1721,7 @@ lfs_newclusterbuf(struct lfs *fs, struct vnode *vp, daddr_t addr, int n)
}
/* Get an empty buffer header, or maybe one with something on it */
s = splbio();
bp = pool_get(&bufpool, PR_WAITOK); /* XXX should use lfs_malloc? */
splx(s);
memset(bp, 0, sizeof(*bp));
BUF_INIT(bp);
bp = getiobuf();
bp->b_flags = B_BUSY | B_CALL;
bp->b_dev = NODEV;
bp->b_blkno = bp->b_lblkno = addr;
@ -2339,9 +2333,7 @@ lfs_cluster_aiodone(struct buf *bp)
/* Fix up the cluster buffer, and release it */
if (cl->flags & LFS_CL_MALLOC)
lfs_free(fs, bp->b_data, LFS_NB_CLUSTER);
s = splbio();
pool_put(&bufpool, bp); /* XXX should use lfs_free? */
splx(s);
putiobuf(bp);
/* Note i/o done */
if (cl->flags & LFS_CL_SYNC) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vfsops.c,v 1.190 2005/12/11 12:25:26 christos Exp $ */
/* $NetBSD: lfs_vfsops.c,v 1.191 2006/01/04 10:13:06 yamt Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.190 2005/12/11 12:25:26 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.191 2006/01/04 10:13:06 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -2072,11 +2072,9 @@ lfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
simple_lock(&global_v_numoutput_slock);
vp->v_numoutput += 2; /* one for biodone, one for aiodone */
simple_unlock(&global_v_numoutput_slock);
mbp = pool_get(&bufpool, PR_WAITOK);
splx(s);
memset(mbp, 0, sizeof(*bp));
BUF_INIT(mbp);
mbp = getiobuf();
UVMHIST_LOG(ubchist, "vp %p mbp %p num now %d bytes 0x%x",
vp, mbp, vp->v_numoutput, bytes);
mbp->b_bufsize = npages << PAGE_SHIFT;
@ -2144,13 +2142,9 @@ lfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
simple_unlock(&global_v_numoutput_slock);
splx(s);
} else {
s = splbio();
bp = pool_get(&bufpool, PR_WAITOK);
bp = getiobuf();
UVMHIST_LOG(ubchist, "vp %p bp %p num now %d",
vp, bp, vp->v_numoutput, 0);
splx(s);
memset(bp, 0, sizeof(*bp));
BUF_INIT(bp);
bp->b_data = (char *)kva +
(vaddr_t)(offset - pg->offset);
bp->b_resid = bp->b_bcount = iobytes;

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_pager.c,v 1.72 2005/11/29 15:45:28 yamt Exp $ */
/* $NetBSD: uvm_pager.c,v 1.73 2006/01/04 10:13:06 yamt Exp $ */
/*
*
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.72 2005/11/29 15:45:28 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.73 2006/01/04 10:13:06 yamt Exp $");
#include "opt_uvmhist.h"
#include "opt_readahead.h"
@ -256,7 +256,7 @@ uvm_aio_biodone1(struct buf *bp)
mbp->b_error = bp->b_error;
}
mbp->b_resid -= bp->b_bcount;
pool_put(&bufpool, bp);
putiobuf(bp);
if (mbp->b_resid == 0) {
biodone(mbp);
}
@ -475,6 +475,6 @@ uvm_aio_aiodone(struct buf *bp)
if (write && (bp->b_flags & B_AGE) != 0) {
vwakeup(bp);
}
pool_put(&bufpool, bp);
putiobuf(bp);
splx(s);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_swap.c,v 1.97 2005/12/11 12:25:29 christos Exp $ */
/* $NetBSD: uvm_swap.c,v 1.98 2006/01/04 10:13:06 yamt 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.97 2005/12/11 12:25:29 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.98 2006/01/04 10:13:06 yamt Exp $");
#include "fs_nfs.h"
#include "opt_uvmhist.h"
@ -1654,16 +1654,13 @@ uvm_swap_io(struct vm_page **pps, int startslot, int npages, int flags)
* now allocate a buf for the i/o.
*/
s = splbio();
bp = pool_get(&bufpool, PR_WAITOK);
splx(s);
bp = getiobuf();
/*
* fill in the bp/sbp. we currently route our i/o through
* /dev/drum's vnode [swapdev_vp].
*/
BUF_INIT(bp);
bp->b_flags = B_BUSY | B_NOCACHE | (flags & (B_READ|B_ASYNC));
bp->b_proc = &proc0; /* XXX */
bp->b_vnbufs.le_next = NOLIST;
@ -1728,7 +1725,7 @@ uvm_swap_io(struct vm_page **pps, int startslot, int npages, int flags)
s = splbio();
if (write)
vwakeup(bp);
pool_put(&bufpool, bp);
putiobuf(bp);
splx(s);
UVMHIST_LOG(pdhist, "<- done (sync) error=%d", error, 0, 0, 0);
return (error);