From: Matthew Dillon Date: Wed, 3 May 2006 20:44:49 +0000 (+0000) Subject: - Clarify the definitions of b_bufsize, b_bcount, and b_resid. X-Git-Tag: v2.0.1~4984 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/9a71d53f1732dd51ac3962df765fad39561f035f - Clarify the definitions of b_bufsize, b_bcount, and b_resid. - Remove unnecessary assignments based on the clarified fields. - Add additional checks for premature EOF. b_bufsize is only used by buffer management entities such as getblk() and other vnode-backed buffer handling procedures. b_bufsize is not required for calls to vn_strategy() or dev_dstrategy(). A number of other subsystems use it to track the original request size. b_bcount is the I/O request size, but b_bcount() is allowed to be truncated by the device chain if the request encompasses EOF (such as on a raw disk device). A caller which needs to record the original buffer size verses the EOF-truncated buffer can compare b_bcount after the I/O against a recorded copy of the original request size. This copy can be recorded in b_bufsize for unmanaged buffers (malloced or getpbuf()'d buffers). b_resid is always relative to b_bcount, not b_bufsize. A successful read that is truncated to the device EOF will thus have a b_resid of 0 and a truncated b_bcount. --- diff --git a/sys/dev/disk/ccd/ccd.c b/sys/dev/disk/ccd/ccd.c index eefeba9600..5acaee13c2 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.27 2006/04/30 17:22:16 dillon Exp $ */ +/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.28 2006/05/03 20:44:46 dillon Exp $ */ /* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */ @@ -1029,6 +1029,10 @@ ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct bio *bio, /* * Fill in the component buf structure. + * + * NOTE: devices do not use b_bufsize, only b_bcount, but b_bcount + * will be truncated on device EOF so we use b_bufsize to detect + * the case. */ cbp = getccdbuf(); cbp->cb_buf.b_flags = bio->bio_buf->b_flags | B_PAGING; @@ -1149,6 +1153,16 @@ ccdiodone(struct bio *bio) cbp->cb_buf.b_bcount); } #endif + /* + * An early EOF is considered an error + */ + if (cbp->cb_buf.b_bcount != cbp->cb_buf.b_bufsize) { + if ((cbp->cb_buf.b_flags & B_ERROR) == 0) { + cbp->cb_buf.b_flags |= B_ERROR; + cbp->cb_buf.b_error = EIO; + } + } + /* * If an error occured, report it. If this is a mirrored * configuration and the first of two possible reads, do not @@ -1231,13 +1245,7 @@ ccdiodone(struct bio *bio) } /* - * use b_bufsize to determine how big the original request was rather - * then b_bcount, because b_bcount may have been truncated for EOF. - * - * XXX We check for an error, but we do not test the resid for an - * aligned EOF condition. This may result in character & block - * device access not recognizing EOF properly when read or written - * sequentially, but will not effect filesystems. + * Use our saved b_bufsize to determine if an unexpected EOF occured. */ count = cbp->cb_buf.b_bufsize; putccdbuf(cbp); diff --git a/sys/dev/disk/vn/vn.c b/sys/dev/disk/vn/vn.c index 46ceaf6ae6..40728d305d 100644 --- a/sys/dev/disk/vn/vn.c +++ b/sys/dev/disk/vn/vn.c @@ -39,7 +39,7 @@ * * from: @(#)vn.c 8.6 (Berkeley) 4/1/94 * $FreeBSD: src/sys/dev/vn/vn.c,v 1.105.2.4 2001/11/18 07:11:00 dillon Exp $ - * $DragonFly: src/sys/dev/disk/vn/vn.c,v 1.19 2006/04/30 17:22:16 dillon Exp $ + * $DragonFly: src/sys/dev/disk/vn/vn.c,v 1.20 2006/05/03 20:44:48 dillon Exp $ */ /* @@ -274,7 +274,6 @@ vnopen(dev_t dev, int flags, int mode, struct thread *td) * * Currently B_ASYNC is only partially handled - for OBJT_SWAP I/O only. */ - static void vnstrategy(dev_t dev, struct bio *bio) { @@ -309,11 +308,12 @@ vnstrategy(dev_t dev, struct bio *bio) * The dscheck() function is called for validating the * slices that exist ON the vnode device itself, and * translate the "slice-relative" block number, again. + * dscheck() will call biodone() and return NULL if + * we are at EOF or beyond the device size. */ if (vn->sc_slices == NULL) { nbio = bio; } else if ((nbio = dscheck(dev, bio, vn->sc_slices)) == NULL) { - bp->b_flags |= B_INVAL; biodone(bio); return; } @@ -367,6 +367,7 @@ vnstrategy(dev_t dev, struct bio *bio) /* * Freeblks is not handled for vnode-backed elements yet. */ + bp->b_resid = 0; biodone(nbio); } else if (vn->sc_vp) { /* @@ -414,9 +415,6 @@ vnstrategy(dev_t dev, struct bio *bio) * * Note: freeblks is not supported with pre-reserved swap. */ - KASSERT((bp->b_bufsize & (vn->sc_secsize - 1)) == 0, - ("vnstrategy: buffer %p too small for physio", bp)); - if (bp->b_cmd == BUF_CMD_FREEBLKS && TESTOPT(vn, VN_RESERVE)) { biodone(nbio); } else { diff --git a/sys/dev/raid/vinum/vinuminterrupt.c b/sys/dev/raid/vinum/vinuminterrupt.c index a07ea3ef4a..19fa3e27bc 100644 --- a/sys/dev/raid/vinum/vinuminterrupt.c +++ b/sys/dev/raid/vinum/vinuminterrupt.c @@ -41,7 +41,7 @@ * * $Id: vinuminterrupt.c,v 1.12 2000/11/24 03:41:42 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinuminterrupt.c,v 1.25.2.3 2001/05/28 05:56:27 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinuminterrupt.c,v 1.9 2006/04/30 17:22:17 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinuminterrupt.c,v 1.10 2006/05/03 20:44:49 dillon Exp $ */ #include "vinumhdr.h" @@ -391,7 +391,6 @@ complete_raid5_write(struct rqelement *rqe) rqe->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ rqe->b.b_data = &ubio->bio_buf->b_data[rqe->useroffset << DEV_BSHIFT]; /* point to the user data */ rqe->b.b_bcount = rqe->datalen << DEV_BSHIFT; /* length to write */ - rqe->b.b_bufsize = rqe->b.b_bcount; /* don't claim more */ rqe->b.b_resid = rqe->b.b_bcount; /* nothing transferred */ rqe->b.b_bio1.bio_offset += (off_t)rqe->dataoffset << DEV_BSHIFT; /* point to the correct block */ dev = DRIVE[rqe->driveno].dev; @@ -431,7 +430,6 @@ complete_raid5_write(struct rqelement *rqe) rqe->b.b_bio1.bio_done = complete_rqe; /* by calling us here */ rqg->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ rqe->b.b_bcount = rqe->buflen << DEV_BSHIFT; /* length to write */ - rqe->b.b_bufsize = rqe->b.b_bcount; /* don't claim we have more */ rqe->b.b_resid = rqe->b.b_bcount; /* nothing transferred */ dev = DRIVE[rqe->driveno].dev; rqe->b.b_bio1.bio_driver_info = dev; diff --git a/sys/dev/raid/vinum/vinumrequest.c b/sys/dev/raid/vinum/vinumrequest.c index fee74091da..b86875ba63 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.11 2006/04/30 17:22:17 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumrequest.c,v 1.12 2006/05/03 20:44:49 dillon Exp $ */ #include "vinumhdr.h" @@ -836,7 +836,6 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex) bp->b_bio1.bio_offset = (off_t)(rqe->sdoffset + sd->driveoffset) << DEV_BSHIFT; /* start address */ bp->b_bcount = rqe->buflen << DEV_BSHIFT; /* number of bytes to transfer */ bp->b_resid = bp->b_bcount; /* and it's still all waiting */ - bp->b_bufsize = bp->b_bcount; /* and buffer size */ if (rqe->flags & XFR_MALLOCED) { /* this operation requires a malloced buffer */ bp->b_data = Malloc(bp->b_bcount); /* get a buffer to put it in */ @@ -947,7 +946,6 @@ 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 | 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 */ sbp->b.b_data = bp->b_data; /* data buffer */ diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 09ed4b2760..29f35a6093 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.20 2006/05/02 19:21:50 dillon Exp $ + * $DragonFly: src/sys/kern/kern_physio.c,v 1.21 2006/05/03 20:44:49 dillon Exp $ */ #include @@ -105,7 +105,6 @@ physio(dev_t dev, struct uio *uio, int ioflag) } else { bp->b_data = uio->uio_iov[i].iov_base; bp->b_bcount = bcount; - bp->b_bufsize = bcount; } dev_dstrategy(dev, &bp->b_bio1); crit_enter(); diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 1ba1939478..a5d5d19f24 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -77,7 +77,7 @@ * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/subr_disk.c,v 1.20.2.6 2001/10/05 07:14:57 peter Exp $ * $FreeBSD: src/sys/ufs/ufs/ufs_disksubr.c,v 1.44.2.3 2001/03/05 05:42:19 obrien Exp $ - * $DragonFly: src/sys/kern/subr_disk.c,v 1.23 2006/04/30 17:22:17 dillon Exp $ + * $DragonFly: src/sys/kern/subr_disk.c,v 1.24 2006/05/03 20:44:49 dillon Exp $ */ #include @@ -470,14 +470,14 @@ diskstrategy(dev_t dev, struct bio *bio) /* * The dscheck() function will also transform the slice relative * block number i.e. bio->bio_offset into a block number that can be - * passed directly to the underlying raw device. + * passed directly to the underlying raw device. If dscheck() + * returns NULL it will have handled the bio for us (e.g. EOF + * or error due to being beyond the device size). */ - nbio = dscheck(dev, bio, dp->d_slice); - if (nbio == NULL) { + if ((nbio = dscheck(dev, bio, dp->d_slice)) != NULL) + dev_dstrategy(dp->d_rawdev, nbio); + else biodone(bio); - return; - } - dev_dstrategy(dp->d_rawdev, nbio); } /* diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index bc79df6bec..5806e9e8ad 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.17 2006/04/30 17:22:17 dillon Exp $ + * $DragonFly: src/sys/kern/subr_diskslice.c,v 1.18 2006/05/03 20:44:49 dillon Exp $ */ #include @@ -220,10 +220,15 @@ doshift: /* beyond partition? */ if (secno + nsec > endsecno) { - /* if exactly at end of disk, return an EOF */ + /* + * If exactly at end of disk, return an EOF. There's no + * point keeping the buffer around so mark it B_INVAL as + * well. + */ if (secno == endsecno) { bp->b_resid = bp->b_bcount; - return (0); + bp->b_flags |= B_INVAL; + return (NULL); } /* or truncate if part of it fits */ nsec = endsecno - secno; @@ -290,11 +295,15 @@ bad_blkno: "dscheck(%s): bio_offset %lld is not on a sector boundary (ssize %d)\n", devtoname(dev), bio->bio_offset, ssp->dss_secsize); bp->b_error = EINVAL; - goto bad; + /* fall through */ bad: + /* + * Terminate the I/O with a ranging error. Since the buffer is + * either illegal or beyond the file EOF, mark it B_INVAL as well. + */ bp->b_resid = bp->b_bcount; - bp->b_flags |= B_ERROR; + bp->b_flags |= B_ERROR | B_INVAL; return (NULL); } diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 27e91bca4b..ea47b90648 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.70 2006/04/30 20:23:24 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_bio.c,v 1.71 2006/05/03 20:44:49 dillon Exp $ */ /* @@ -700,7 +700,8 @@ bwrite(struct buf * bp) vfs_busy_pages(bp->b_vp, bp); /* - * Normal bwrites pipeline writes + * Normal bwrites pipeline writes. NOTE: b_bufsize is only + * valid for vnode-backed buffers. */ bp->b_runningbufspace = bp->b_bufsize; runningbufspace += bp->b_runningbufspace; @@ -1021,10 +1022,7 @@ brelse(struct buf * bp) * * Normally we can do this whether a buffer is B_DELWRI or not. If * the buffer is an NFS buffer, it is tracking piecemeal writes or - * the commit state and we cannot afford to lose the buffer. If the - * buffer has a background write in progress, we need to keep it - * around to prevent it from being reconstituted and starting a second - * background write. + * the commit state and we cannot afford to lose the buffer. */ if ((bp->b_flags & B_VMIO) && !(bp->b_vp->v_tag == VT_NFS && diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 1d980e9a81..45582cbe00 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.23 2006/04/30 18:52:36 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.24 2006/05/03 20:44:49 dillon Exp $ */ #include "opt_debug_cluster.h" @@ -510,10 +510,14 @@ cluster_callback(struct bio *bio) int error = 0; /* - * Must propogate errors to all the components. + * Must propogate errors to all the components. A short read (EOF) + * is a critical error. */ - if (bp->b_flags & B_ERROR) + if (bp->b_flags & B_ERROR) { error = bp->b_error; + } else if (bp->b_bcount != bp->b_bufsize) { + panic("cluster_callback: unexpected EOF on cluster %p!", bio); + } pmap_qremove(trunc_page((vm_offset_t) bp->b_data), bp->b_xio.xio_npages); /* @@ -787,8 +791,10 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) } /* - * We got a pbuf to make the cluster in. - * so initialise it. + * Set up the pbuf. Track our append point with b_bcount + * and b_bufsize. b_bufsize is not used by the device but + * our caller uses it to loop clusters and we use it to + * detect a premature EOF on the block device. */ bp->b_bcount = 0; bp->b_bufsize = 0; diff --git a/sys/sys/buf.h b/sys/sys/buf.h index ea7534435b..b311395b8a 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.33 2006/04/30 20:23:25 dillon Exp $ + * $DragonFly: src/sys/sys/buf.h,v 1.34 2006/05/03 20:44:49 dillon Exp $ */ #ifndef _SYS_BUF_H_ @@ -111,17 +111,32 @@ typedef enum buf_cmd { * The buffer header describes an I/O operation in the kernel. * * NOTES: - * b_bufsize, b_bcount. b_bufsize is the allocation size of the - * buffer, either DEV_BSIZE or PAGE_SIZE aligned. b_bcount is the - * originally requested buffer size and can serve as a bounds check - * against EOF. For most, but not all uses, b_bcount == b_bufsize. + * b_bufsize represents the filesystem block size (for this particular + * block) and/or the allocation size or original request size. This + * field is NOT USED by lower device layers. VNode and device + * strategy routines WILL NEVER ACCESS THIS FIELD. * - * b_dirtyoff, b_dirtyend. Buffers support piecemeal, unaligned - * ranges of dirty data that need to be written to backing store. - * The range is typically clipped at b_bcount ( not b_bufsize ). + * b_bcount represents the EOF-clipped request size. It is typically + * set to b_bufsize prior to I/O initiation and may be modified by + * the driver chain (for example, to clip upon encountering the end + * of the block device). b_bcount may only be clipped to represent + * EOF - for example, it would be clipped to the symlink length when + * reading a symlink, or to the file EOF. It is never clipped due to + * an error, nor is it clipped on a zero-fill short read. For byte + * oriented files b_bcount is typically set to b_bufsize to initiate + * the read or write to the underlying block device, then clipped to + * the file EOF upon completion of the read or write. * * b_resid. Number of bytes remaining in I/O. After an I/O operation - * completes, b_resid is usually 0 indicating 100% success. + * completes, b_resid is usually 0 indicating 100% success. Note however + * that if the device chain encounters an EOF, both b_resid and b_bcount + * will be truncated. So b_resid will also be 0 if a short-read (EOF) + * occurs and the caller must check for the EOF condition by comparing + * b_bcount against (typically) b_bufsize. + * + * b_dirtyoff, b_dirtyend. Buffers support piecemeal, unaligned + * ranges of dirty data that need to be written to backing store. + * The range is typically clipped at b_bcount (not b_bufsize). * * b_bio1 and b_bio2 represent the two primary I/O layers. Additional * I/O layers are allocated out of the object cache and may also exist. diff --git a/sys/vfs/specfs/spec_vnops.c b/sys/vfs/specfs/spec_vnops.c index e558c2e6ca..ec7f5987ca 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.39 2006/04/30 17:22:18 dillon Exp $ + * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.40 2006/05/03 20:44:49 dillon Exp $ */ #include @@ -694,9 +694,8 @@ spec_getpages(struct vop_getpages_args *ap) /* Build a minimal buffer header. */ bp->b_cmd = BUF_CMD_READ; bp->b_bcount = size; - bp->b_bufsize = size; bp->b_resid = 0; - bp->b_runningbufspace = bp->b_bufsize; + bp->b_runningbufspace = size; runningbufspace += bp->b_runningbufspace; bp->b_bio1.bio_offset = offset; @@ -716,22 +715,25 @@ spec_getpages(struct vop_getpages_args *ap) crit_exit(); - if ((bp->b_flags & B_ERROR) != 0) { + if (bp->b_flags & B_ERROR) { if (bp->b_error) error = bp->b_error; else error = EIO; } - nread = size - bp->b_resid; - - if (nread < ap->a_count) { - bzero((caddr_t)kva + nread, - ap->a_count - nread); - } + /* + * If EOF is encountered we must zero-extend the result in order + * to ensure that the page does not contain garabge. When no + * error occurs, an early EOF is indicated if b_bcount got truncated. + * b_resid is relative to b_bcount and should be 0, but some devices + * might indicate an EOF with b_resid instead of truncating b_bcount. + */ + nread = bp->b_bcount - bp->b_resid; + if (nread < ap->a_count) + bzero((caddr_t)kva + nread, ap->a_count - nread); pmap_qremove(kva, pcount); - gotreqpage = 0; for (i = 0, toff = 0; i < pcount; i++, toff = nextoff) { nextoff = toff + PAGE_SIZE; diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 110d9cf0e8..7ef4a9242f 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.23 2006/04/30 18:25:37 dillon Exp $ + * $DragonFly: src/sys/vm/swap_pager.c,v 1.24 2006/05/03 20:44:49 dillon Exp $ */ #include @@ -968,7 +968,6 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) * Flush the biox to the swap device. */ if (bufx->b_bcount) { - bufx->b_bufsize = bufx->b_bcount; if (bufx->b_cmd != BUF_CMD_READ) bufx->b_dirtyend = bufx->b_bcount; BUF_KERNPROC(bufx); @@ -1034,7 +1033,6 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) bufx->b_dirtyend = bufx->b_bcount; } if (bufx->b_bcount) { - bufx->b_bufsize = bufx->b_bcount; if (bufx->b_cmd != BUF_CMD_READ) bufx->b_dirtyend = bufx->b_bcount; BUF_KERNPROC(bufx); @@ -1254,7 +1252,6 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) bp->b_data = (caddr_t) kva; bp->b_bcount = PAGE_SIZE * (j - i); - bp->b_bufsize = PAGE_SIZE * (j - i); bio->bio_done = swp_pager_async_iodone; bio->bio_offset = (off_t)(blk - (reqpage - i)) << PAGE_SHIFT; bio->bio_driver_info = (void *)(reqpage - i); @@ -1487,7 +1484,6 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t sync, pmap_qenter((vm_offset_t)bp->b_data, &m[i], n); bp->b_bcount = PAGE_SIZE * n; - bp->b_bufsize = PAGE_SIZE * n; bio->bio_offset = (off_t)blk << PAGE_SHIFT; for (j = 0; j < n; ++j) { diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 0a4518a467..d0bfb11aaf 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.21 2006/04/30 18:52:37 dillon Exp $ + * $DragonFly: src/sys/vm/vm_pager.c,v 1.22 2006/05/03 20:44:49 dillon Exp $ */ /* @@ -325,6 +325,8 @@ initpbuf(struct buf *bp) bp->b_flags = B_PAGING; bp->b_cmd = BUF_CMD_DONE; bp->b_error = 0; + bp->b_bcount = 0; + bp->b_bufsize = MAXPHYS; initbufbio(bp); xio_init(&bp->b_xio); BUF_LOCK(bp, LK_EXCLUSIVE); diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 1895d95c29..24c6a1cba3 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.25 2006/04/30 17:22:18 dillon Exp $ + * $DragonFly: src/sys/vm/vnode_pager.c,v 1.26 2006/05/03 20:44:49 dillon Exp $ */ /* @@ -455,8 +455,7 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t m) bp->b_bio1.bio_done = vnode_pager_iodone; bp->b_bio1.bio_offset = doffset; bp->b_bcount = bsize; - bp->b_bufsize = bsize; - bp->b_runningbufspace = bp->b_bufsize; + bp->b_runningbufspace = bsize; runningbufspace += bp->b_runningbufspace; bp->b_cmd = BUF_CMD_READ; @@ -764,8 +763,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, bp->b_bio1.bio_done = vnode_pager_iodone; bp->b_bio1.bio_offset = firstaddr; bp->b_bcount = size; - bp->b_bufsize = size; - bp->b_runningbufspace = bp->b_bufsize; + bp->b_runningbufspace = size; runningbufspace += bp->b_runningbufspace; bp->b_cmd = BUF_CMD_READ;