svn commit: r248500 - in head/sys: fs/nfsclient nfsclient
Ed Maste
emaste at FreeBSD.org
Tue Mar 19 13:06:12 UTC 2013
Author: emaste
Date: Tue Mar 19 13:06:11 2013
New Revision: 248500
URL: http://svnweb.freebsd.org/changeset/base/248500
Log:
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@
Modified:
head/sys/fs/nfsclient/nfs_clbio.c
head/sys/nfsclient/nfs_bio.c
Modified: head/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clbio.c Tue Mar 19 12:52:13 2013 (r248499)
+++ head/sys/fs/nfsclient/nfs_clbio.c Tue Mar 19 13:06:11 2013 (r248500)
@@ -484,7 +484,7 @@ ncl_bioread(struct vnode *vp, struct uio
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 @@ flush_and_restart:
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, struc
*/
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;
Modified: head/sys/nfsclient/nfs_bio.c
==============================================================================
--- head/sys/nfsclient/nfs_bio.c Tue Mar 19 12:52:13 2013 (r248499)
+++ head/sys/nfsclient/nfs_bio.c Tue Mar 19 13:06:11 2013 (r248500)
@@ -475,7 +475,7 @@ nfs_bioread(struct vnode *vp, struct uio
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 @@ flush_and_restart:
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, struc
*/
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;
More information about the svn-src-head
mailing list