mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=248500
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue