From 337def89635a6514e00fe37e1144bc6c3b2452dd Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Sun, 14 Jan 1996 20:32:14 +0000 Subject: [PATCH] Fixed an overflowing multiplication in vnstrategy() by replacing it with the standard macro dbtob(). The non-B_PAGING case now works well enough to run newfs on a 32GB virtual drive. Fixed numerous bogus variable types and one overflowing multiplication in the B_PAGING case of vnstrategy(). Swapping to virtual drives larger than 2GB might work now. --- sys/dev/vn/vn.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c index 7e8c756ded99..0212e51920e4 100644 --- a/sys/dev/vn/vn.c +++ b/sys/dev/vn/vn.c @@ -232,7 +232,7 @@ vnstrategy(struct buf *bp) register struct vn_softc *vn = vn_softc[unit]; register daddr_t bn; int error; - int sz; + long sz; struct uio auio; struct iovec aiov; @@ -272,7 +272,7 @@ vnstrategy(struct buf *bp) aiov.iov_len = bp->b_bcount; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; - auio.uio_offset = bn*DEV_BSIZE; + auio.uio_offset = dbtob(bn); auio.uio_segflg = UIO_SYSSPACE; if( bp->b_flags & B_READ) auio.uio_rw = UIO_READ; @@ -291,15 +291,14 @@ vnstrategy(struct buf *bp) bp->b_flags |= B_ERROR; biodone(bp); } else { - daddr_t bsize; - int flags, resid; + long bsize, resid; + off_t byten; + int flags; caddr_t addr; - struct buf *nbp; nbp = getvnbuf(); - - bn = dbtob(bn); + byten = dbtob(bn); bsize = vn->sc_vp->v_mount->mnt_stat.f_iosize; addr = bp->b_data; flags = bp->b_flags | B_CALL; @@ -309,14 +308,15 @@ vnstrategy(struct buf *bp) int off, s, nra; nra = 0; - error = VOP_BMAP(vn->sc_vp, bn / bsize, &vp, &nbn, &nra, NULL); - if (error == 0 && (long)nbn == -1) + error = VOP_BMAP(vn->sc_vp, (daddr_t)(byten / bsize), + &vp, &nbn, &nra, NULL); + if (error == 0 && nbn == -1) error = EIO; IFOPT(vn, VN_DONTCLUSTER) nra = 0; - off = bn % bsize; + off = byten % bsize; if (off) sz = bsize - off; else @@ -333,8 +333,11 @@ vnstrategy(struct buf *bp) } IFOPT(vn,VN_IO) - printf("vnstrategy: vp %p/%p bn 0x%lx/0x%lx sz 0x%x\n", - vn->sc_vp, vp, bn, nbn, sz); + printf( + /* XXX no %qx in kernel. Synthesize it. */ + "vnstrategy: vp %p/%p bn 0x%lx%08lx/0x%lx sz 0x%x\n", + vn->sc_vp, vp, (long)(byten >> 32), + (u_long)byten, nbn, sz); nbp->b_flags = flags; nbp->b_bcount = sz; @@ -376,7 +379,7 @@ vnstrategy(struct buf *bp) return; } - bn += sz; + byten += sz; addr += sz; resid -= sz; }