Fix remainder calculation when biosize is not a power of 2
In common configurations biosize is a power of two, but is not required to be so. Thanks to markj@ for spotting an additional case beyond my original patch. Reviewed by: rmacklem@
This commit is contained in:
parent
565d8205f3
commit
96ecfd9813
@ -484,7 +484,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
|
|||||||
case VREG:
|
case VREG:
|
||||||
NFSINCRGLOBAL(newnfsstats.biocache_reads);
|
NFSINCRGLOBAL(newnfsstats.biocache_reads);
|
||||||
lbn = uio->uio_offset / biosize;
|
lbn = uio->uio_offset / biosize;
|
||||||
on = uio->uio_offset & (biosize - 1);
|
on = uio->uio_offset - (lbn * biosize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the read ahead(s), as required.
|
* Start the read ahead(s), as required.
|
||||||
@ -1029,7 +1029,7 @@ flush_and_restart:
|
|||||||
do {
|
do {
|
||||||
NFSINCRGLOBAL(newnfsstats.biocache_writes);
|
NFSINCRGLOBAL(newnfsstats.biocache_writes);
|
||||||
lbn = uio->uio_offset / biosize;
|
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);
|
n = MIN((unsigned)(biosize - on), uio->uio_resid);
|
||||||
again:
|
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);
|
error = vtruncbuf(vp, cred, nsize, biosize);
|
||||||
lbn = nsize / biosize;
|
lbn = nsize / biosize;
|
||||||
bufsize = nsize & (biosize - 1);
|
bufsize = nsize - (lbn * biosize);
|
||||||
bp = nfs_getcacheblk(vp, lbn, bufsize, td);
|
bp = nfs_getcacheblk(vp, lbn, bufsize, td);
|
||||||
if (!bp)
|
if (!bp)
|
||||||
return EINTR;
|
return EINTR;
|
||||||
|
@ -475,7 +475,7 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
|
|||||||
case VREG:
|
case VREG:
|
||||||
nfsstats.biocache_reads++;
|
nfsstats.biocache_reads++;
|
||||||
lbn = uio->uio_offset / biosize;
|
lbn = uio->uio_offset / biosize;
|
||||||
on = uio->uio_offset & (biosize - 1);
|
on = uio->uio_offset - (lbn * biosize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the read ahead(s), as required.
|
* Start the read ahead(s), as required.
|
||||||
@ -1011,7 +1011,7 @@ flush_and_restart:
|
|||||||
do {
|
do {
|
||||||
nfsstats.biocache_writes++;
|
nfsstats.biocache_writes++;
|
||||||
lbn = uio->uio_offset / biosize;
|
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);
|
n = MIN((unsigned)(biosize - on), uio->uio_resid);
|
||||||
again:
|
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);
|
error = vtruncbuf(vp, cred, nsize, biosize);
|
||||||
lbn = nsize / biosize;
|
lbn = nsize / biosize;
|
||||||
bufsize = nsize & (biosize - 1);
|
bufsize = nsize - (lbn * biosize);
|
||||||
bp = nfs_getcacheblk(vp, lbn, bufsize, td);
|
bp = nfs_getcacheblk(vp, lbn, bufsize, td);
|
||||||
if (!bp)
|
if (!bp)
|
||||||
return EINTR;
|
return EINTR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user