From a8f169e23a89d6f2ef1249aef8031ba4b9f9d602 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 28 Apr 2006 16:34:02 +0000 Subject: [PATCH] Get rid of pbgetvp() and pbrelvp(). Instead fold the B_PAGING flag directly into getpbuf() (the only type of buffer that pbgetvp() could be called on anyway). Change related b_flags assignments from '=' to '|='. Get rid of remaining depdendancies on b_vp. vn_strategy() now relies solely on the vp passed to it as an argument. Remove buffer cache code that sets b_vp for anonymous pbuf's. Add a stopgap 'vp' argument to vfs_busy_pages(). This is only really needed by NFS and the clustering code do to the severely hackish nature of the NFS and clustering code. Fix a bug in the ext2fs inode code where vfs_busy_pages() was being called on B_CACHE buffers. Add an assertion to vfs_busy_pages() to panic if it encounters a B_CACHE buffer. --- sys/bus/cam/cam_periph.c | 4 ++-- sys/dev/disk/ata/ata-raid.c | 6 +++--- sys/dev/disk/ccd/ccd.c | 27 +++++++++++++------------- sys/dev/disk/fd/fd.c | 4 ++-- sys/dev/raid/vinum/vinumio.c | 4 ++-- sys/dev/raid/vinum/vinumrequest.c | 5 +++-- sys/dev/raid/vinum/vinumrevive.c | 8 ++++---- sys/kern/kern_physio.c | 8 +++++--- sys/kern/subr_diskslice.c | 4 ++-- sys/kern/vfs_aio.c | 4 ++-- sys/kern/vfs_bio.c | 26 ++++++++++++++----------- sys/kern/vfs_cluster.c | 25 ++++++++++++++---------- sys/kern/vfs_default.c | 3 +-- sys/kern/vfs_subr.c | 32 +------------------------------ sys/sys/buf.h | 6 ++---- sys/vfs/gnu/ext2fs/ext2_bmap.c | 4 ++-- sys/vfs/gnu/ext2fs/ext2_inode.c | 7 ++++--- sys/vfs/nfs/nfs_bio.c | 18 ++++++++--------- sys/vfs/nfs/nfs_vnops.c | 15 +++------------ sys/vfs/specfs/spec_vnops.c | 5 ++--- sys/vfs/ufs/ffs_inode.c | 4 ++-- sys/vfs/ufs/ffs_rawread.c | 7 +++---- sys/vfs/ufs/ufs_bmap.c | 4 ++-- sys/vm/swap_pager.c | 23 +++++++--------------- sys/vm/vm_pager.c | 8 +++----- sys/vm/vnode_pager.c | 8 +++----- 26 files changed, 113 insertions(+), 156 deletions(-) diff --git a/sys/bus/cam/cam_periph.c b/sys/bus/cam/cam_periph.c index 8bc2f38d58..78cf0f7cb9 100644 --- a/sys/bus/cam/cam_periph.c +++ b/sys/bus/cam/cam_periph.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/cam/cam_periph.c,v 1.24.2.3 2003/01/25 19:04:40 dillon Exp $ - * $DragonFly: src/sys/bus/cam/cam_periph.c,v 1.12 2006/04/28 00:24:44 dillon Exp $ + * $DragonFly: src/sys/bus/cam/cam_periph.c,v 1.13 2006/04/28 16:33:57 dillon Exp $ */ #include @@ -598,7 +598,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) mapinfo->bp[i]->b_bufsize = lengths[i]; /* set the flags */ - mapinfo->bp[i]->b_flags = flags[i]; + mapinfo->bp[i]->b_flags |= flags[i]; /* map the buffer into kernel memory */ if (vmapbuf(mapinfo->bp[i]) < 0) { diff --git a/sys/dev/disk/ata/ata-raid.c b/sys/dev/disk/ata/ata-raid.c index 7e1155464e..3621c8f2ee 100644 --- a/sys/dev/disk/ata/ata-raid.c +++ b/sys/dev/disk/ata/ata-raid.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/ata-raid.c,v 1.3.2.19 2003/01/30 07:19:59 sos Exp $ - * $DragonFly: src/sys/dev/disk/ata/ata-raid.c,v 1.17 2006/03/24 18:35:30 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/ata-raid.c,v 1.18 2006/04/28 16:33:58 dillon Exp $ */ #include "opt_ata.h" @@ -558,7 +558,7 @@ arstrategy(dev_t dev, struct bio *bio) buf1->bp.b_bio1.bio_caller_info1.ptr = (void *)rdp; buf1->bp.b_bcount = chunk * DEV_BSIZE; buf1->bp.b_data = data; - buf1->bp.b_flags = bp->b_flags; + buf1->bp.b_flags = bp->b_flags | B_PAGING; buf1->bp.b_bio1.bio_done = ar_done; buf1->org = bio; buf1_blkno = (int)(buf1->bp.b_bio1.bio_offset >> DEV_BSHIFT); @@ -692,7 +692,7 @@ ar_done(struct bio *bio) buf->drive = buf->drive + rdp->width; else buf->drive = buf->drive - rdp->width; - buf->bp.b_flags = buf->org->bio_buf->b_flags; + buf->bp.b_flags = buf->org->bio_buf->b_flags | B_PAGING; buf->bp.b_error = 0; dev_dstrategy(AD_SOFTC(rdp->disks[buf->drive])->dev, &buf->bp.b_bio1); diff --git a/sys/dev/disk/ccd/ccd.c b/sys/dev/disk/ccd/ccd.c index 3fa3b0480b..1d4fee6f83 100644 --- a/sys/dev/disk/ccd/ccd.c +++ b/sys/dev/disk/ccd/ccd.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/ccd/ccd.c,v 1.73.2.1 2001/09/11 09:49:52 kris Exp $ */ -/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.25 2006/04/03 02:02:32 dillon Exp $ */ +/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.26 2006/04/28 16:33:59 dillon Exp $ */ /* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */ @@ -150,6 +150,7 @@ SYSCTL_INT(_debug, OID_AUTO, ccddebug, CTLFLAG_RW, &ccddebug, 0, ""); struct ccdbuf { struct buf cb_buf; /* new I/O buf */ + struct vnode *cb_vp; /* related vnode */ struct bio *cb_obio; /* ptr. to original I/O buf */ struct ccdbuf *cb_freenext; /* free list link */ int cb_unit; /* target unit */ @@ -875,10 +876,10 @@ ccdstart(struct ccd_softc *cs, struct bio *bio) * also try to avoid hogging. */ if ((cbp[0]->cb_buf.b_flags & B_READ) == 0) { - vn_strategy(cbp[0]->cb_buf.b_vp, - &cbp[0]->cb_buf.b_bio1); - vn_strategy(cbp[1]->cb_buf.b_vp, - &cbp[1]->cb_buf.b_bio1); + vn_strategy(cbp[0]->cb_vp, + &cbp[0]->cb_buf.b_bio1); + vn_strategy(cbp[1]->cb_vp, + &cbp[1]->cb_buf.b_bio1); } else { int pick = cs->sc_pick; daddr_t range = cs->sc_size / 16 * cs->sc_label.d_secsize; @@ -889,14 +890,14 @@ ccdstart(struct ccd_softc *cs, struct bio *bio) cs->sc_pick = pick = 1 - pick; } cs->sc_blk[pick] = doffset + rcount; - vn_strategy(cbp[pick]->cb_buf.b_vp, - &cbp[pick]->cb_buf.b_bio1); + vn_strategy(cbp[pick]->cb_vp, + &cbp[pick]->cb_buf.b_bio1); } } else { /* * Not mirroring */ - vn_strategy(cbp[0]->cb_buf.b_vp, + vn_strategy(cbp[0]->cb_vp, &cbp[0]->cb_buf.b_bio1); } doffset += rcount; @@ -1030,9 +1031,9 @@ ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct bio *bio, * Fill in the component buf structure. */ cbp = getccdbuf(); - cbp->cb_buf.b_flags = bio->bio_buf->b_flags; + cbp->cb_buf.b_flags = bio->bio_buf->b_flags | B_PAGING; cbp->cb_buf.b_data = addr; - cbp->cb_buf.b_vp = ci->ci_vp; + cbp->cb_vp = ci->ci_vp; if (cs->sc_ileave == 0) cbc = dbtob((off_t)(ci->ci_size - cbn)); else @@ -1068,9 +1069,9 @@ ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct bio *bio, /* mirror, setup second I/O */ cbp = getccdbuf(); - cbp->cb_buf.b_flags = bio->bio_buf->b_flags; + cbp->cb_buf.b_flags = bio->bio_buf->b_flags | B_PAGING; cbp->cb_buf.b_data = addr; - cbp->cb_buf.b_vp = ci2->ci_vp; + cbp->cb_vp = ci2->ci_vp; if (cs->sc_ileave == 0) cbc = dbtob((off_t)(ci->ci_size - cbn)); else @@ -1215,7 +1216,7 @@ ccdiodone(struct bio *bio) cbp->cb_mirror->cb_pflags |= CCDPF_MIRROR_DONE; vn_strategy( - cbp->cb_mirror->cb_buf.b_vp, + cbp->cb_mirror->cb_vp, &cbp->cb_mirror->cb_buf.b_bio1 ); putccdbuf(cbp); diff --git a/sys/dev/disk/fd/fd.c b/sys/dev/disk/fd/fd.c index 6ec119aa38..5c31ca86e5 100644 --- a/sys/dev/disk/fd/fd.c +++ b/sys/dev/disk/fd/fd.c @@ -51,7 +51,7 @@ * * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 * $FreeBSD: src/sys/isa/fd.c,v 1.176.2.8 2002/05/15 21:56:14 joerg Exp $ - * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.27 2006/04/28 00:24:45 dillon Exp $ + * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.28 2006/04/28 16:34:00 dillon Exp $ * */ @@ -2174,7 +2174,7 @@ fdformat(dev_t dev, struct fd_formb *finfo, struct thread *td) BUF_LOCKINIT(bp); BUF_LOCK(bp, LK_EXCLUSIVE); initbufbio(bp); - bp->b_flags = B_FORMAT; + bp->b_flags = B_FORMAT | B_PAGING; /* * calculate a fake blkno, so fdstrategy() would initiate a diff --git a/sys/dev/raid/vinum/vinumio.c b/sys/dev/raid/vinum/vinumio.c index 9bc3f0df7d..dee0944354 100644 --- a/sys/dev/raid/vinum/vinumio.c +++ b/sys/dev/raid/vinum/vinumio.c @@ -35,7 +35,7 @@ * * $Id: vinumio.c,v 1.30 2000/05/10 23:23:30 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumio.c,v 1.52.2.6 2002/05/02 08:43:44 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumio.c,v 1.11 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumio.c,v 1.12 2006/04/28 16:34:00 dillon Exp $ */ #include "vinumhdr.h" @@ -323,7 +323,7 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag) int len = min(length, MAXBSIZE); /* maximum block device transfer is MAXBSIZE */ bp = geteblk(len); /* get a buffer header */ - bp->b_flags = flag; + bp->b_flags |= flag; bp->b_bio1.bio_offset = offset; /* disk offset */ bp->b_saveaddr = bp->b_data; bp->b_data = buf; diff --git a/sys/dev/raid/vinum/vinumrequest.c b/sys/dev/raid/vinum/vinumrequest.c index 29267de9ec..39a361b70d 100644 --- a/sys/dev/raid/vinum/vinumrequest.c +++ b/sys/dev/raid/vinum/vinumrequest.c @@ -39,7 +39,7 @@ * * $Id: vinumrequest.c,v 1.30 2001/01/09 04:20:55 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumrequest.c,v 1.44.2.5 2002/08/28 04:30:56 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumrequest.c,v 1.9 2006/03/26 07:56:54 swildner Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumrequest.c,v 1.10 2006/04/28 16:34:00 dillon Exp $ */ #include "vinumhdr.h" @@ -811,6 +811,7 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex) /* Initialize the buf struct */ /* copy these flags from user bp */ bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_READ | B_ASYNC); + bp->b_flags |= B_PAGING; #ifdef VINUMDEBUG if (rqe->flags & XFR_BUFLOCKED) /* paranoia */ panic("build_rq_buffer: rqe already locked"); /* XXX remove this when we're sure */ @@ -944,7 +945,7 @@ sdio(struct bio *bio) } sddev = DRIVE[sd->driveno].dev; /* device */ bzero(sbp, sizeof(struct sdbuf)); /* start with nothing */ - sbp->b.b_flags = bp->b_flags; + sbp->b.b_flags = bp->b_flags | B_PAGING; sbp->b.b_bufsize = bp->b_bufsize; /* buffer size */ sbp->b.b_bcount = bp->b_bcount; /* number of bytes to transfer */ sbp->b.b_resid = bp->b_resid; /* and amount waiting */ diff --git a/sys/dev/raid/vinum/vinumrevive.c b/sys/dev/raid/vinum/vinumrevive.c index fe59c7e8a8..d91947376f 100644 --- a/sys/dev/raid/vinum/vinumrevive.c +++ b/sys/dev/raid/vinum/vinumrevive.c @@ -39,7 +39,7 @@ * * $Id: vinumrevive.c,v 1.14 2000/12/21 01:55:11 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumrevive.c,v 1.22.2.5 2001/03/13 02:59:43 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumrevive.c,v 1.8 2006/03/26 07:56:54 swildner Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumrevive.c,v 1.9 2006/04/28 16:34:01 dillon Exp $ */ #include "vinumhdr.h" @@ -164,7 +164,7 @@ revive_block(int sdno) else /* it's an unattached plex */ dev = VINUM_PLEX(sd->plexno); /* create the device number */ - bp->b_flags = B_READ; /* either way, read it */ + bp->b_flags = B_READ | B_PAGING; /* either way, read it */ vinumstart(dev, &bp->b_bio1, 1); biowait(bp); } @@ -175,7 +175,7 @@ revive_block(int sdno) /* Now write to the subdisk */ { dev = VINUM_SD(sdno); /* create the device number */ - bp->b_flags = B_ORDERED | B_WRITE; /* and make this an ordered write */ + bp->b_flags = B_ORDERED | B_WRITE | B_PAGING; /* and make this an ordered write */ bp->b_resid = bp->b_bcount; bp->b_bio1.bio_offset = (off_t)sd->revived << DEV_BSHIFT; /* write it to here */ bp->b_bio1.bio_driver_info = dev; @@ -413,7 +413,7 @@ parityrebuild(struct plex *plex, bpp[sdno]->b_bio1.bio_driver_info = VINUM_SD(plex->sdnos[psd]); /* write back to the parity SD */ else bpp[sdno]->b_bio1.bio_driver_info = VINUM_SD(plex->sdnos[sdno]); /* device number */ - bpp[sdno]->b_flags = B_READ; /* either way, read it */ + bpp[sdno]->b_flags = B_READ | B_PAGING; /* either way, read it */ bpp[sdno]->b_bcount = mysize; bpp[sdno]->b_resid = bpp[sdno]->b_bcount; bpp[sdno]->b_bio1.bio_offset = (off_t)pstripe << DEV_BSHIFT; /* transfer from here */ diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index a2b3c39131..bfc39d7361 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -17,7 +17,7 @@ * are met. * * $FreeBSD: src/sys/kern/kern_physio.c,v 1.46.2.4 2003/11/14 09:51:47 simokawa Exp $ - * $DragonFly: src/sys/kern/kern_physio.c,v 1.16 2006/04/28 00:24:46 dillon Exp $ + * $DragonFly: src/sys/kern/kern_physio.c,v 1.17 2006/04/28 16:34:01 dillon Exp $ */ #include @@ -44,12 +44,14 @@ physio(dev_t dev, struct uio *uio, int ioflag) int i; int error; int chk_blockno; + int saflags; caddr_t sa; u_int iolen; struct buf *bp; bp = getpbuf(NULL); sa = bp->b_data; + saflags = bp->b_flags; error = 0; /* XXX: sanity check */ @@ -68,9 +70,9 @@ physio(dev_t dev, struct uio *uio, int ioflag) for (i = 0; i < uio->uio_iovcnt; i++) { while (uio->uio_iov[i].iov_len) { if (uio->uio_rw == UIO_READ) - bp->b_flags = B_READ; + bp->b_flags = saflags | B_READ; else - bp->b_flags = B_WRITE; + bp->b_flags = saflags | B_WRITE; bp->b_data = uio->uio_iov[i].iov_base; bp->b_bcount = uio->uio_iov[i].iov_len; bp->b_saveaddr = sa; diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index 242d4e0cc5..7bd5cf161a 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -44,7 +44,7 @@ * from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 * from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $ * $FreeBSD: src/sys/kern/subr_diskslice.c,v 1.82.2.6 2001/07/24 09:49:41 dd Exp $ - * $DragonFly: src/sys/kern/subr_diskslice.c,v 1.15 2006/04/03 02:02:35 dillon Exp $ + * $DragonFly: src/sys/kern/subr_diskslice.c,v 1.16 2006/04/28 16:34:01 dillon Exp $ */ #include @@ -537,7 +537,7 @@ dsiodone(struct bio *bio) struct buf *bp = bio->bio_buf; char *msg; - bp->b_flags = bp->b_flags & ~B_DONE; + bp->b_flags &= ~B_DONE; if (!(bp->b_flags & B_READ) || (!(bp->b_flags & B_ERROR) && bp->b_error == 0)) { msg = fixlabel(NULL, bio->bio_caller_info1.ptr, diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index b865ed2c30..2551ca96c5 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -14,7 +14,7 @@ * of the author. This software is distributed AS-IS. * * $FreeBSD: src/sys/kern/vfs_aio.c,v 1.70.2.28 2003/05/29 06:15:35 alc Exp $ - * $DragonFly: src/sys/kern/vfs_aio.c,v 1.22 2006/04/28 00:24:46 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_aio.c,v 1.23 2006/04/28 16:34:01 dillon Exp $ */ /* @@ -961,7 +961,7 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe) bp->b_bcount = cb->aio_nbytes; bp->b_bufsize = cb->aio_nbytes; - bp->b_flags = (cb->aio_lio_opcode == LIO_WRITE ? B_WRITE : B_READ); + bp->b_flags |= (cb->aio_lio_opcode == LIO_WRITE ? B_WRITE : B_READ); bp->b_bio1.bio_done = aio_physwakeup; bp->b_saveaddr = bp->b_data; bp->b_data = (void *)(uintptr_t)cb->aio_buf; diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 6dc8ec11e6..c61bb8ee29 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -12,7 +12,7 @@ * John S. Dyson. * * $FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.20 2003/05/28 18:38:10 alc Exp $ - * $DragonFly: src/sys/kern/vfs_bio.c,v 1.65 2006/04/28 06:13:54 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_bio.c,v 1.66 2006/04/28 16:34:01 dillon Exp $ */ /* @@ -604,7 +604,7 @@ bread(struct vnode * vp, off_t loffset, int size, struct buf ** bpp) KASSERT(!(bp->b_flags & B_ASYNC), ("bread: illegal async bp %p", bp)); bp->b_flags |= B_READ; bp->b_flags &= ~(B_ERROR | B_INVAL); - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); vn_strategy(vp, &bp->b_bio1); return (biowait(bp)); } @@ -620,7 +620,7 @@ bread(struct vnode * vp, off_t loffset, int size, struct buf ** bpp) * and we do not have to do anything. */ int -breadn(struct vnode * vp, off_t loffset, int size, off_t *raoffset, +breadn(struct vnode *vp, off_t loffset, int size, off_t *raoffset, int *rabsize, int cnt, struct buf ** bpp) { struct buf *bp, *rabp; @@ -633,7 +633,7 @@ breadn(struct vnode * vp, off_t loffset, int size, off_t *raoffset, if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; bp->b_flags &= ~(B_ERROR | B_INVAL); - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); vn_strategy(vp, &bp->b_bio1); ++readwait; } @@ -646,7 +646,7 @@ breadn(struct vnode * vp, off_t loffset, int size, off_t *raoffset, if ((rabp->b_flags & B_CACHE) == 0) { rabp->b_flags |= B_READ | B_ASYNC; rabp->b_flags &= ~(B_ERROR | B_INVAL); - vfs_busy_pages(rabp, 0); + vfs_busy_pages(vp, rabp, 0); BUF_KERNPROC(rabp); vn_strategy(vp, &rabp->b_bio1); } else { @@ -695,7 +695,7 @@ bwrite(struct buf * bp) bp->b_flags &= ~(B_READ | B_DONE | B_ERROR); bp->b_flags |= B_CACHE; - vfs_busy_pages(bp, 1); + vfs_busy_pages(bp->b_vp, bp, 1); /* * Normal bwrites pipeline writes @@ -3064,13 +3064,18 @@ vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, int pageno, vm_page_t m) * and should be ignored. */ void -vfs_busy_pages(struct buf *bp, int clear_modify) +vfs_busy_pages(struct vnode *vp, struct buf *bp, int clear_modify) { int i, bogus; struct proc *p = curthread->td_proc; + /* + * clear_modify is 0 when setting up for a read. B_CACHE + * had better not be set. + */ + KKASSERT(clear_modify || (bp->b_flags & B_CACHE) == 0); + if (bp->b_flags & B_VMIO) { - struct vnode *vp = bp->b_vp; vm_object_t obj; vm_ooffset_t foff; @@ -3114,10 +3119,9 @@ retry: */ vm_page_protect(m, VM_PROT_NONE); - if (clear_modify) + if (clear_modify) { vfs_page_set_valid(bp, foff, i, m); - else if (m->valid == VM_PAGE_BITS_ALL && - (bp->b_flags & B_CACHE) == 0) { + } else if (m->valid == VM_PAGE_BITS_ALL) { bp->b_xio.xio_pages[i] = bogus_page; bogus++; } diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 6af8c0f91d..56ac738047 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -34,7 +34,7 @@ * * @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94 * $FreeBSD: src/sys/kern/vfs_cluster.c,v 1.92.2.9 2001/11/18 07:10:59 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.20 2006/03/26 07:56:54 swildner Exp $ + * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.21 2006/04/28 16:34:01 dillon Exp $ */ #include "opt_debug_cluster.h" @@ -240,7 +240,8 @@ single_block_read: no_read_ahead: /* - * Handle the synchronous read + * Handle the synchronous read. This only occurs if B_CACHE was + * not set. */ if (bp) { #if defined(CLUSTERDEBUG) @@ -249,7 +250,7 @@ no_read_ahead: bp->b_loffset, bp->b_bcount, seqcount); #endif if ((bp->b_flags & B_CLUSTER) == 0) { - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); } bp->b_flags &= ~(B_ERROR|B_INVAL); if ((bp->b_flags & B_ASYNC) || bp->b_bio1.bio_done != NULL) @@ -285,7 +286,7 @@ no_read_ahead: #endif if ((rbp->b_flags & B_CLUSTER) == 0) { - vfs_busy_pages(rbp, 0); + vfs_busy_pages(vp, rbp, 0); } rbp->b_flags &= ~(B_ERROR|B_INVAL); if ((rbp->b_flags & B_ASYNC) || rbp->b_bio1.bio_done != NULL) @@ -331,7 +332,7 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, return tbp; bp = trypbuf(&cluster_pbuf_freecnt); - if (bp == 0) + if (bp == NULL) return tbp; /* @@ -342,7 +343,7 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, */ bp->b_data = (char *)((vm_offset_t)bp->b_data | ((vm_offset_t)tbp->b_data & PAGE_MASK)); - bp->b_flags = B_ASYNC | B_READ | B_CLUSTER | B_VMIO; + bp->b_flags |= B_ASYNC | B_READ | B_CLUSTER | B_VMIO; bp->b_bio1.bio_done = cluster_callback; bp->b_bio1.bio_caller_info1.cluster_head = NULL; bp->b_bio1.bio_caller_info2.cluster_tail = NULL; @@ -350,7 +351,6 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, bp->b_bio2.bio_offset = NOOFFSET; KASSERT(bp->b_loffset != NOOFFSET, ("cluster_rbuild: no buffer offset")); - pbgetvp(vp, bp); bp->b_bcount = 0; bp->b_bufsize = 0; @@ -800,12 +800,12 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) */ bp->b_data = (char *)((vm_offset_t)bp->b_data | ((vm_offset_t)tbp->b_data & PAGE_MASK)); - bp->b_flags |= B_CLUSTER | + bp->b_flags &= ~(B_READ | B_DONE | B_ERROR); + bp->b_flags |= B_CLUSTER | B_ASYNC | (tbp->b_flags & (B_VMIO | B_NEEDCOMMIT | B_NOWDRAIN)); bp->b_bio1.bio_done = cluster_callback; bp->b_bio1.bio_caller_info1.cluster_head = NULL; bp->b_bio1.bio_caller_info2.cluster_tail = NULL; - pbgetvp(vp, bp); /* * From this location in the file, scan forward to see * if there are buffers with adjacent data that need to @@ -925,7 +925,12 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) totalwritten += bp->b_bufsize; bp->b_dirtyoff = 0; bp->b_dirtyend = bp->b_bufsize; - bawrite(bp); + + vfs_busy_pages(vp, bp, 1); + bp->b_runningbufspace = bp->b_bufsize; + runningbufspace += bp->b_runningbufspace; + BUF_KERNPROC(bp); /* B_ASYNC */ + vn_strategy(vp, &bp->b_bio1); bytes -= i; } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index a2db0a90c6..d41e47624d 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -37,7 +37,7 @@ * * * $FreeBSD: src/sys/kern/vfs_default.c,v 1.28.2.7 2003/01/10 18:23:26 bde Exp $ - * $DragonFly: src/sys/kern/vfs_default.c,v 1.33 2006/04/23 03:08:02 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_default.c,v 1.34 2006/04/28 16:34:01 dillon Exp $ */ #include @@ -1145,7 +1145,6 @@ vop_nostrategy (struct vop_strategy_args *ap) { printf("No strategy for buffer at %p\n", ap->a_bio->bio_buf); vprint("", ap->a_vp); - vprint("", ap->a_bio->bio_buf->b_vp); ap->a_bio->bio_buf->b_flags |= B_ERROR; ap->a_bio->bio_buf->b_error = EOPNOTSUPP; biodone(ap->a_bio); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index e5ae5cfb60..85b0b38837 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -37,7 +37,7 @@ * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 * $FreeBSD: src/sys/kern/vfs_subr.c,v 1.249.2.30 2003/04/04 20:35:57 tegge Exp $ - * $DragonFly: src/sys/kern/vfs_subr.c,v 1.78 2006/04/25 22:11:28 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_subr.c,v 1.79 2006/04/28 16:34:01 dillon Exp $ */ /* @@ -843,36 +843,6 @@ brelvp(struct buf *bp) vdrop(vp); } -/* - * Associate a p-buffer with a vnode. - * - * Also sets B_PAGING flag to indicate that vnode is not fully associated - * with the buffer. i.e. the bp has not been linked into the vnode or - * ref-counted. - */ -void -pbgetvp(struct vnode *vp, struct buf *bp) -{ - KASSERT(bp->b_vp == NULL, ("pbgetvp: not free")); - KKASSERT((bp->b_flags & B_HASHED) == 0); - - bp->b_vp = vp; - bp->b_flags |= B_PAGING; -} - -/* - * Disassociate a p-buffer from a vnode. - */ -void -pbrelvp(struct buf *bp) -{ - KASSERT(bp->b_vp != NULL, ("pbrelvp: NULL")); - KKASSERT((bp->b_flags & B_HASHED) == 0); - - bp->b_vp = NULL; - bp->b_flags &= ~B_PAGING; -} - /* * Reassign the buffer to the proper clean/dirty list based on B_DELWRI. * This routine is called when the state of the B_DELWRI bit is changed. diff --git a/sys/sys/buf.h b/sys/sys/buf.h index a398d07077..0c7e7e827a 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -37,7 +37,7 @@ * * @(#)buf.h 8.9 (Berkeley) 3/30/95 * $FreeBSD: src/sys/sys/buf.h,v 1.88.2.10 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/sys/buf.h,v 1.29 2006/04/28 06:13:55 dillon Exp $ + * $DragonFly: src/sys/sys/buf.h,v 1.30 2006/04/28 16:34:01 dillon Exp $ */ #ifndef _SYS_BUF_H_ @@ -374,15 +374,13 @@ int physio (dev_t dev, struct uio *uio, int ioflag); #define physwrite physio void vfs_bio_set_validclean (struct buf *, int base, int size); void vfs_bio_clrbuf (struct buf *); -void vfs_busy_pages (struct buf *, int clear_modify); +void vfs_busy_pages (struct vnode *, struct buf *, int clear_modify); void vfs_unbusy_pages (struct buf *); int vmapbuf (struct buf *); void vunmapbuf (struct buf *); void relpbuf (struct buf *, int *); void brelvp (struct buf *); void bgetvp (struct vnode *, struct buf *); -void pbgetvp (struct vnode *, struct buf *); -void pbrelvp (struct buf *); int allocbuf (struct buf *bp, int size); int scan_all_buffers (int (*)(struct buf *, void *), void *); void reassignbuf (struct buf *); diff --git a/sys/vfs/gnu/ext2fs/ext2_bmap.c b/sys/vfs/gnu/ext2fs/ext2_bmap.c index e48bc98f2d..1b81c1930a 100644 --- a/sys/vfs/gnu/ext2fs/ext2_bmap.c +++ b/sys/vfs/gnu/ext2fs/ext2_bmap.c @@ -37,7 +37,7 @@ * * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95 * $FreeBSD: src/sys/ufs/ufs/ufs_bmap.c,v 1.34.2.1 2000/03/17 10:12:14 ps Exp $ - * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_bmap.c,v 1.1 2006/04/04 17:34:32 dillon Exp $ + * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_bmap.c,v 1.2 2006/04/28 16:34:01 dillon Exp $ */ #include @@ -217,7 +217,7 @@ ext2_bmaparray(struct vnode *vp, ext2_daddr_t bn, ext2_daddr_t *bnp, bp->b_bio2.bio_offset = fsbtodoff(fs, daddr); bp->b_flags |= B_READ; bp->b_flags &= ~(B_INVAL|B_ERROR); - vfs_busy_pages(bp, 0); + vfs_busy_pages(bp->b_vp, bp, 0); vn_strategy(bp->b_vp, &bp->b_bio1); error = biowait(bp); if (error) { diff --git a/sys/vfs/gnu/ext2fs/ext2_inode.c b/sys/vfs/gnu/ext2fs/ext2_inode.c index c4927d7d4b..7c746553d7 100644 --- a/sys/vfs/gnu/ext2fs/ext2_inode.c +++ b/sys/vfs/gnu/ext2fs/ext2_inode.c @@ -38,7 +38,7 @@ * * @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93 * $FreeBSD: src/sys/gnu/ext2fs/ext2_inode.c,v 1.24.2.1 2000/08/03 00:52:57 peter Exp $ - * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_inode.c,v 1.15 2006/04/07 06:38:30 dillon Exp $ + * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_inode.c,v 1.16 2006/04/28 16:34:01 dillon Exp $ */ #include "opt_quota.h" @@ -402,12 +402,13 @@ ext2_indirtrunc(struct inode *ip, daddr_t lbn, off_t doffset, daddr_t lastbn, bp = getblk(vp, lblktodoff(fs, lbn), (int)fs->s_blocksize, 0, 0); if (bp->b_flags & (B_DONE | B_DELWRI)) { /* nop */ - } else { + } else if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; + bp->b_flags &= ~(B_ERROR | B_INVAL); if (bp->b_bcount > bp->b_bufsize) panic("ext2_indirtrunc: bad buffer size"); bp->b_bio2.bio_offset = doffset; - vfs_busy_pages(bp, 0); + vfs_busy_pages(bp->b_vp, bp, 0); vn_strategy(vp, &bp->b_bio1); error = biowait(bp); } diff --git a/sys/vfs/nfs/nfs_bio.c b/sys/vfs/nfs/nfs_bio.c index 3cdc63e23b..a35a9952e5 100644 --- a/sys/vfs/nfs/nfs_bio.c +++ b/sys/vfs/nfs/nfs_bio.c @@ -35,7 +35,7 @@ * * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 * $FreeBSD: /repoman/r/ncvs/src/sys/nfsclient/nfs_bio.c,v 1.130 2004/04/14 23:23:55 peadar Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_bio.c,v 1.32 2006/04/28 00:24:46 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_bio.c,v 1.33 2006/04/28 16:34:01 dillon Exp $ */ @@ -434,8 +434,8 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag) if (!rabp) return (EINTR); if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { - rabp->b_flags |= (B_READ | B_ASYNC); - vfs_busy_pages(rabp, 0); + rabp->b_flags |= B_READ | B_ASYNC; + vfs_busy_pages(vp, rabp, 0); if (nfs_asyncio(vp, &rabp->b_bio2, td)) { rabp->b_flags |= B_INVAL|B_ERROR; vfs_unbusy_pages(rabp); @@ -496,7 +496,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { brelse(bp); @@ -524,7 +524,7 @@ again: return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { bp->b_flags |= B_ERROR; @@ -550,7 +550,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { brelse(bp); @@ -579,7 +579,7 @@ again: return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); error = nfs_doio(vp, &bp->b_bio2, td); /* * no error + B_INVAL == directory EOF, @@ -623,7 +623,7 @@ again: if (rabp) { if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { rabp->b_flags |= (B_READ | B_ASYNC); - vfs_busy_pages(rabp, 0); + vfs_busy_pages(vp, rabp, 0); if (nfs_asyncio(vp, &rabp->b_bio2, td)) { rabp->b_flags |= B_INVAL|B_ERROR; vfs_unbusy_pages(rabp); @@ -945,7 +945,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { brelse(bp); diff --git a/sys/vfs/nfs/nfs_vnops.c b/sys/vfs/nfs/nfs_vnops.c index c11145af44..9416f3cc39 100644 --- a/sys/vfs/nfs/nfs_vnops.c +++ b/sys/vfs/nfs/nfs_vnops.c @@ -35,7 +35,7 @@ * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 * $FreeBSD: src/sys/nfs/nfs_vnops.c,v 1.150.2.5 2001/12/20 19:56:28 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_vnops.c,v 1.56 2006/04/28 00:24:46 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_vnops.c,v 1.57 2006/04/28 16:34:01 dillon Exp $ */ @@ -94,15 +94,6 @@ #define TRUE 1 #define FALSE 0 -/* - * Ifdef for FreeBSD-current merged buffer cache. It is unfortunate that these - * calls are not in getblk() and brelse() so that they would not be necessary - * here. - */ -#ifndef B_VMIO -#define vfs_busy_pages(bp, f) -#endif - static int nfsspec_read (struct vop_read_args *); static int nfsspec_write (struct vop_write_args *); static int nfsfifo_read (struct vop_read_args *); @@ -3104,7 +3095,7 @@ nfs_flush_bp(struct buf *bp, void *data) * Note: to avoid loopback deadlocks, we do not * assign b_runningbufspace. */ - vfs_busy_pages(bp, 1); + vfs_busy_pages(bp->b_vp, bp, 1); info->bvary[info->bvsize] = bp; toff = bp->b_bio2.bio_offset + bp->b_dirtyoff; @@ -3276,7 +3267,7 @@ nfs_writebp(struct buf *bp, int force, struct thread *td) * Note: to avoid loopback deadlocks, we do not * assign b_runningbufspace. */ - vfs_busy_pages(bp, 1); + vfs_busy_pages(bp->b_vp, bp, 1); BUF_KERNPROC(bp); if (bp->b_flags & B_ASYNC) { diff --git a/sys/vfs/specfs/spec_vnops.c b/sys/vfs/specfs/spec_vnops.c index 845b7e0080..a0ee82ad31 100644 --- a/sys/vfs/specfs/spec_vnops.c +++ b/sys/vfs/specfs/spec_vnops.c @@ -32,7 +32,7 @@ * * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95 * $FreeBSD: src/sys/miscfs/specfs/spec_vnops.c,v 1.131.2.4 2001/02/26 04:23:20 jlemon Exp $ - * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.37 2006/04/28 00:24:46 dillon Exp $ + * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.38 2006/04/28 16:34:01 dillon Exp $ */ #include @@ -691,9 +691,8 @@ spec_getpages(struct vop_getpages_args *ap) pmap_qenter(kva, ap->a_m, pcount); /* Build a minimal buffer header. */ - bp->b_flags = B_READ; + bp->b_flags |= B_READ; - pbgetvp(ap->a_vp, bp); bp->b_bcount = size; bp->b_bufsize = size; bp->b_resid = 0; diff --git a/sys/vfs/ufs/ffs_inode.c b/sys/vfs/ufs/ffs_inode.c index 788cc56bdd..eb1f375e96 100644 --- a/sys/vfs/ufs/ffs_inode.c +++ b/sys/vfs/ufs/ffs_inode.c @@ -32,7 +32,7 @@ * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 * $FreeBSD: src/sys/ufs/ffs/ffs_inode.c,v 1.56.2.5 2002/02/05 18:35:03 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.19 2006/04/07 06:38:33 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.20 2006/04/28 16:34:01 dillon Exp $ */ #include "opt_quota.h" @@ -462,7 +462,7 @@ ffs_indirtrunc(struct inode *ip, ufs_daddr_t lbn, ufs_daddr_t dbn, if (bp->b_bcount > bp->b_bufsize) panic("ffs_indirtrunc: bad buffer size"); bp->b_bio2.bio_offset = dbtodoff(fs, dbn); - vfs_busy_pages(bp, 0); + vfs_busy_pages(vp, bp, 0); /* * Access the block device layer using the device vnode * and the translated block number (bio2) instead of the diff --git a/sys/vfs/ufs/ffs_rawread.c b/sys/vfs/ufs/ffs_rawread.c index a55f8b8e89..b7a1a708ec 100644 --- a/sys/vfs/ufs/ffs_rawread.c +++ b/sys/vfs/ufs/ffs_rawread.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ufs/ffs/ffs_rawread.c,v 1.3.2.2 2003/05/29 06:15:35 alc Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_rawread.c,v 1.19 2006/04/28 00:24:46 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_rawread.c,v 1.20 2006/04/28 16:34:01 dillon Exp $ */ #include @@ -171,7 +171,8 @@ ffs_rawread_readahead(struct vnode *vp, caddr_t udata, off_t loffset, if (iolen != 0) bp->b_bcount -= PAGE_SIZE; } - bp->b_flags = B_READ; + bp->b_flags &= ~(/*B_READ|*/B_DONE|B_ERROR); + bp->b_flags |= B_READ; bp->b_data = udata; bp->b_saveaddr = sa; bp->b_loffset = loffset; @@ -264,7 +265,6 @@ ffs_rawread_main(struct vnode *vp, struct uio *uio) /* XXX: Leave some bufs for swap */ bp = getpbuf(&ffsrawbufcnt); sa = bp->b_data; - bp->b_vp = vp; error = ffs_rawread_readahead(vp, udata, offset, resid, td, bp, sa, &baseticks); if (error != 0) @@ -278,7 +278,6 @@ ffs_rawread_main(struct vnode *vp, struct uio *uio) nbp = NULL; if (nbp != NULL) { nsa = nbp->b_data; - nbp->b_vp = vp; nerror = ffs_rawread_readahead( vp, diff --git a/sys/vfs/ufs/ufs_bmap.c b/sys/vfs/ufs/ufs_bmap.c index 3c83f629c6..d466e4af0e 100644 --- a/sys/vfs/ufs/ufs_bmap.c +++ b/sys/vfs/ufs/ufs_bmap.c @@ -37,7 +37,7 @@ * * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95 * $FreeBSD: src/sys/ufs/ufs/ufs_bmap.c,v 1.34.2.1 2000/03/17 10:12:14 ps Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_bmap.c,v 1.10 2006/03/24 18:35:34 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_bmap.c,v 1.11 2006/04/28 16:34:01 dillon Exp $ */ #include @@ -210,7 +210,7 @@ ufs_bmaparray(struct vnode *vp, ufs_daddr_t bn, ufs_daddr_t *bnp, bp->b_bio2.bio_offset = fsbtodoff(fs, daddr); bp->b_flags |= B_READ; bp->b_flags &= ~(B_INVAL|B_ERROR); - vfs_busy_pages(bp, 0); + vfs_busy_pages(bp->b_vp, bp, 0); vn_strategy(bp->b_vp, &bp->b_bio1); error = biowait(bp); if (error) { diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index bd42f884e6..6cab8fbfdb 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -96,7 +96,7 @@ * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94 * * $FreeBSD: src/sys/vm/swap_pager.c,v 1.130.2.12 2002/08/31 21:15:55 dillon Exp $ - * $DragonFly: src/sys/vm/swap_pager.c,v 1.20 2006/03/27 01:54:18 dillon Exp $ + * $DragonFly: src/sys/vm/swap_pager.c,v 1.21 2006/04/28 16:34:02 dillon Exp $ */ #include @@ -870,7 +870,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) bp->b_error = EINVAL; bp->b_flags |= B_ERROR | B_INVAL; biodone(bio); - printf("swap_pager_strategy: bp %p b_vp %p offset %lld size %d, not page bounded\n", bp, bp->b_vp, bio->bio_offset, (int)bp->b_bcount); + printf("swap_pager_strategy: bp %p offset %lld size %d, not page bounded\n", bp, bio->bio_offset, (int)bp->b_bcount); return; } @@ -970,7 +970,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) if ((bufx->b_flags & B_READ) == 0) bufx->b_dirtyend = bufx->b_bcount; BUF_KERNPROC(bufx); - vn_strategy(bufx->b_vp, biox); + vn_strategy(swapdev_vp, biox); } else { biodone(biox); } @@ -998,10 +998,9 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) bufx = getpbuf(NULL); biox = &bufx->b_bio1; cluster_append(nbio, bufx); - bufx->b_flags = (bufx->b_flags & B_ORDERED) | + bufx->b_flags |= (bufx->b_flags & B_ORDERED) | (bp->b_flags & B_READ) | B_ASYNC; - pbgetvp(swapdev_vp, bufx); biox->bio_done = swap_chain_iodone; biox->bio_offset = (off_t)blk << PAGE_SHIFT; biox->bio_caller_info1.cluster_parent = nbio; @@ -1037,7 +1036,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) if ((bufx->b_flags & B_READ) == 0) bufx->b_dirtyend = bufx->b_bcount; BUF_KERNPROC(bufx); - vn_strategy(bufx->b_vp, biox); + vn_strategy(swapdev_vp, biox); } else { biodone(biox); } @@ -1242,13 +1241,11 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) /* * map our page(s) into kva for input - * - * NOTE: B_PAGING is set by pbgetvp() */ pmap_qenter(kva, m + i, j - i); - bp->b_flags = B_READ; + bp->b_flags |= B_READ; bp->b_data = (caddr_t) kva; bp->b_bcount = PAGE_SIZE * (j - i); bp->b_bufsize = PAGE_SIZE * (j - i); @@ -1266,8 +1263,6 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) } bp->b_xio.xio_npages = j - i; - pbgetvp(swapdev_vp, bp); - mycpu->gd_cnt.v_swapin++; mycpu->gd_cnt.v_swappgsin += bp->b_xio.xio_npages; @@ -1474,15 +1469,13 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t sync, /* * All I/O parameters have been satisfied, build the I/O * request and assign the swap space. - * - * NOTE: B_PAGING is set by pbgetvp() */ if (sync == TRUE) { bp = getpbuf(&nsw_wcount_sync); } else { bp = getpbuf(&nsw_wcount_async); - bp->b_flags = B_ASYNC; + bp->b_flags |= B_ASYNC; } bio = &bp->b_bio1; @@ -1492,8 +1485,6 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t sync, bp->b_bufsize = PAGE_SIZE * n; bio->bio_offset = (off_t)blk << PAGE_SHIFT; - pbgetvp(swapdev_vp, bp); - for (j = 0; j < n; ++j) { vm_page_t mreq = m[i+j]; diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index c0c3fe4407..22cd9e65ff 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_pager.c,v 1.54.2.2 2001/11/18 07:11:00 dillon Exp $ - * $DragonFly: src/sys/vm/vm_pager.c,v 1.17 2006/03/27 01:54:18 dillon Exp $ + * $DragonFly: src/sys/vm/vm_pager.c,v 1.18 2006/04/28 16:34:02 dillon Exp $ */ /* @@ -319,7 +319,7 @@ initpbuf(struct buf *bp) bp->b_kvabase = bp->b_data; bp->b_kvasize = MAXPHYS; bp->b_xflags = 0; - bp->b_flags = 0; + bp->b_flags = B_PAGING; bp->b_error = 0; initbufbio(bp); xio_init(&bp->b_xio); @@ -410,9 +410,7 @@ relpbuf(struct buf *bp, int *pfreecnt) { crit_enter(); - if (bp->b_vp) - pbrelvp(bp); - + KKASSERT(bp->b_flags & B_PAGING); BUF_UNLOCK(bp); TAILQ_INSERT_HEAD(&bswlist, bp, b_freelist); diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 65fdb9e029..a950b23009 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -39,7 +39,7 @@ * * from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91 * $FreeBSD: src/sys/vm/vnode_pager.c,v 1.116.2.7 2002/12/31 09:34:51 dillon Exp $ - * $DragonFly: src/sys/vm/vnode_pager.c,v 1.23 2006/03/27 01:54:18 dillon Exp $ + * $DragonFly: src/sys/vm/vnode_pager.c,v 1.24 2006/04/28 16:34:02 dillon Exp $ */ /* @@ -451,11 +451,10 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t m) bp = getpbuf(&vnode_pbuf_freecnt); /* build a minimal buffer header */ - bp->b_flags = B_READ; + bp->b_flags |= B_READ; bp->b_data = (caddr_t) kva + i * bsize; bp->b_bio1.bio_done = vnode_pager_iodone; bp->b_bio1.bio_offset = doffset; - pbgetvp(dp, bp); bp->b_bcount = bsize; bp->b_bufsize = bsize; bp->b_runningbufspace = bp->b_bufsize; @@ -763,10 +762,9 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, pmap_qenter(kva, m, count); /* build a minimal buffer header */ - bp->b_flags = B_READ; + bp->b_flags |= B_READ; bp->b_bio1.bio_done = vnode_pager_iodone; bp->b_bio1.bio_offset = firstaddr; - pbgetvp(dp, bp); bp->b_bcount = size; bp->b_bufsize = size; bp->b_runningbufspace = bp->b_bufsize; -- 2.41.0