diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index 4a3ef41ac988..21ab88072239 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -484,7 +484,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) case VREG: NFSINCRGLOBAL(newnfsstats.biocache_reads); lbn = uio->uio_offset / biosize; - on = uio->uio_offset & (biosize - 1); + on = uio->uio_offset - (lbn * biosize); /* * Start the read ahead(s), as required. @@ -1029,7 +1029,7 @@ ncl_write(struct vop_write_args *ap) do { NFSINCRGLOBAL(newnfsstats.biocache_writes); lbn = uio->uio_offset / biosize; - on = uio->uio_offset & (biosize-1); + on = uio->uio_offset - (lbn * biosize); n = MIN((unsigned)(biosize - on), uio->uio_resid); again: /* @@ -1847,7 +1847,7 @@ ncl_meta_setsize(struct vnode *vp, struct ucred *cred, struct thread *td, u_quad */ error = vtruncbuf(vp, cred, nsize, biosize); lbn = nsize / biosize; - bufsize = nsize & (biosize - 1); + bufsize = nsize - (lbn * biosize); bp = nfs_getcacheblk(vp, lbn, bufsize, td); if (!bp) return EINTR; diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index a90afea1b8b5..b7fe832eb4c8 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -475,7 +475,7 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) case VREG: nfsstats.biocache_reads++; lbn = uio->uio_offset / biosize; - on = uio->uio_offset & (biosize - 1); + on = uio->uio_offset - (lbn * biosize); /* * Start the read ahead(s), as required. @@ -1011,7 +1011,7 @@ nfs_write(struct vop_write_args *ap) do { nfsstats.biocache_writes++; lbn = uio->uio_offset / biosize; - on = uio->uio_offset & (biosize-1); + on = uio->uio_offset - (lbn * biosize); n = MIN((unsigned)(biosize - on), uio->uio_resid); again: /* @@ -1781,7 +1781,7 @@ nfs_meta_setsize(struct vnode *vp, struct ucred *cred, struct thread *td, u_quad */ error = vtruncbuf(vp, cred, nsize, biosize); lbn = nsize / biosize; - bufsize = nsize & (biosize - 1); + bufsize = nsize - (lbn * biosize); bp = nfs_getcacheblk(vp, lbn, bufsize, td); if (!bp) return EINTR;