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.
This commit is contained in:
Bruce Evans 1996-01-14 20:32:14 +00:00
parent 04ecd93b2a
commit 337def8963
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13427

View File

@ -232,7 +232,7 @@ vnstrategy(struct buf *bp)
register struct vn_softc *vn = vn_softc[unit]; register struct vn_softc *vn = vn_softc[unit];
register daddr_t bn; register daddr_t bn;
int error; int error;
int sz; long sz;
struct uio auio; struct uio auio;
struct iovec aiov; struct iovec aiov;
@ -272,7 +272,7 @@ vnstrategy(struct buf *bp)
aiov.iov_len = bp->b_bcount; aiov.iov_len = bp->b_bcount;
auio.uio_iov = &aiov; auio.uio_iov = &aiov;
auio.uio_iovcnt = 1; auio.uio_iovcnt = 1;
auio.uio_offset = bn*DEV_BSIZE; auio.uio_offset = dbtob(bn);
auio.uio_segflg = UIO_SYSSPACE; auio.uio_segflg = UIO_SYSSPACE;
if( bp->b_flags & B_READ) if( bp->b_flags & B_READ)
auio.uio_rw = UIO_READ; auio.uio_rw = UIO_READ;
@ -291,15 +291,14 @@ vnstrategy(struct buf *bp)
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;
biodone(bp); biodone(bp);
} else { } else {
daddr_t bsize; long bsize, resid;
int flags, resid; off_t byten;
int flags;
caddr_t addr; caddr_t addr;
struct buf *nbp; struct buf *nbp;
nbp = getvnbuf(); nbp = getvnbuf();
byten = dbtob(bn);
bn = dbtob(bn);
bsize = vn->sc_vp->v_mount->mnt_stat.f_iosize; bsize = vn->sc_vp->v_mount->mnt_stat.f_iosize;
addr = bp->b_data; addr = bp->b_data;
flags = bp->b_flags | B_CALL; flags = bp->b_flags | B_CALL;
@ -309,14 +308,15 @@ vnstrategy(struct buf *bp)
int off, s, nra; int off, s, nra;
nra = 0; nra = 0;
error = VOP_BMAP(vn->sc_vp, bn / bsize, &vp, &nbn, &nra, NULL); error = VOP_BMAP(vn->sc_vp, (daddr_t)(byten / bsize),
if (error == 0 && (long)nbn == -1) &vp, &nbn, &nra, NULL);
if (error == 0 && nbn == -1)
error = EIO; error = EIO;
IFOPT(vn, VN_DONTCLUSTER) IFOPT(vn, VN_DONTCLUSTER)
nra = 0; nra = 0;
off = bn % bsize; off = byten % bsize;
if (off) if (off)
sz = bsize - off; sz = bsize - off;
else else
@ -333,8 +333,11 @@ vnstrategy(struct buf *bp)
} }
IFOPT(vn,VN_IO) IFOPT(vn,VN_IO)
printf("vnstrategy: vp %p/%p bn 0x%lx/0x%lx sz 0x%x\n", printf(
vn->sc_vp, vp, bn, nbn, sz); /* 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_flags = flags;
nbp->b_bcount = sz; nbp->b_bcount = sz;
@ -376,7 +379,7 @@ vnstrategy(struct buf *bp)
return; return;
} }
bn += sz; byten += sz;
addr += sz; addr += sz;
resid -= sz; resid -= sz;
} }