fuse4bsd
changeset 252:6e862286739e tip
fix a bug due to which file sizes were taken modulo 4GB in certain I/O operations
Bug found, diagnosed, and original fix submitted by Jakub Kruszona-Zawadzki
The bug was caused by forced casts of arguments of the min() function.
It was fixed by using macros for min/max operations.
Bug found, diagnosed, and original fix submitted by Jakub Kruszona-Zawadzki
The bug was caused by forced casts of arguments of the min() function.
It was fixed by using macros for min/max operations.
| author | at node: creo.hu, nick: csaba |
|---|---|
| date | Fri Feb 27 00:21:58 2009 +0200 (17 months ago) |
| parents | 498acaef33b0 |
| children | |
| files | fuse_module/fuse_io.c |
| line | diff |
|---|
| 1 | --- a/fuse_module/fuse_io.c Tue Feb 05 07:25:57 2008 +0200 |
| 2 | +++ b/fuse_module/fuse_io.c Fri Feb 27 00:21:58 2009 +0200 |
| 3 | @@ -227,7 +227,7 @@ fuse_read_biobackend(struct fuse_io_data |
| 4 | return (0); |
| 5 | |
| 6 | biosize = vp->v_mount->mnt_stat.f_iosize; |
| 7 | - bcount = min(MAXBSIZE, biosize); |
| 8 | + bcount = MIN(MAXBSIZE, biosize); |
| 9 | |
| 10 | DEBUG2G("entering loop\n"); |
| 11 | do { |
| 12 | @@ -352,7 +352,7 @@ fuse_read_directbackend(struct fuse_io_d |
| 13 | fri = fdi.indata; |
| 14 | fri->fh = fufh->fh_id; |
| 15 | fri->offset = uio->uio_offset; |
| 16 | - fri->size = min(uio->uio_resid, |
| 17 | + fri->size = MIN(uio->uio_resid, |
| 18 | fusefs_get_data(vp->v_mount)->max_read); |
| 19 | |
| 20 | DEBUG2G("fri->fh %llu, fri->offset %d, fri->size %d\n", |
| 21 | @@ -399,7 +399,7 @@ fuse_io_p2p(struct fuse_io_data *fioda, |
| 22 | while (uio->uio_resid > 0) { |
| 23 | int transfersize; |
| 24 | |
| 25 | - chunksize = min(iov->iov_len, nmax); |
| 26 | + chunksize = MIN(iov->iov_len, nmax); |
| 27 | |
| 28 | if (uio->uio_rw == UIO_READ) { |
| 29 | struct fuse_read_in *fri; |
| 30 | @@ -464,7 +464,7 @@ fuse_std_buffeater(struct uio *uio, size |
| 31 | { |
| 32 | int err; |
| 33 | |
| 34 | - if ((err = uiomove(buf, min(reqsize, bufsize), uio))) |
| 35 | + if ((err = uiomove(buf, MIN(reqsize, bufsize), uio))) |
| 36 | return (err); |
| 37 | |
| 38 | if (bufsize < reqsize) |
| 39 | @@ -502,7 +502,7 @@ fuse_write_directbackend(struct fuse_io_ |
| 40 | } |
| 41 | |
| 42 | while (uio->uio_resid > 0) { |
| 43 | - chunksize = min(uio->uio_resid, |
| 44 | + chunksize = MIN(uio->uio_resid, |
| 45 | fusefs_get_data(vp->v_mount)->max_write); |
| 46 | |
| 47 | fdi.iosize = sizeof(*fwi) + chunksize; |
| 48 | @@ -569,7 +569,7 @@ fuse_write_biobackend(struct fuse_io_dat |
| 49 | do { |
| 50 | lbn = uio->uio_offset / biosize; |
| 51 | on = uio->uio_offset & (biosize-1); |
| 52 | - n = min((unsigned)(biosize - on), uio->uio_resid); |
| 53 | + n = MIN((unsigned)(biosize - on), uio->uio_resid); |
| 54 | |
| 55 | DEBUG2G("lbn %d, on %d, n %d, uio offset %d, uio resid %d\n", |
| 56 | (int)lbn, on, n, (int)uio->uio_offset, uio->uio_resid); |
| 57 | @@ -739,8 +739,8 @@ again: |
| 58 | */ |
| 59 | if (n) { |
| 60 | if (bp->b_dirtyend > 0) { |
| 61 | - bp->b_dirtyoff = min(on, bp->b_dirtyoff); |
| 62 | - bp->b_dirtyend = max((on + n), bp->b_dirtyend); |
| 63 | + bp->b_dirtyoff = MIN(on, bp->b_dirtyoff); |
| 64 | + bp->b_dirtyend = MAX((on + n), bp->b_dirtyend); |
| 65 | } else { |
| 66 | bp->b_dirtyoff = on; |
| 67 | bp->b_dirtyend = on + n; |
| 68 | @@ -831,7 +831,7 @@ fuse_strategy_i(struct vnode *vp, struct |
| 69 | bp->b_resid = bp->b_bcount; |
| 70 | while (bp->b_resid > 0) { |
| 71 | DEBUG2G("starting bio with resid %ld\n", bp->b_resid); |
| 72 | - chunksize = min(bp->b_resid, |
| 73 | + chunksize = MIN(bp->b_resid, |
| 74 | fusefs_get_data(vp->v_mount)->max_read); |
| 75 | fdi.iosize = sizeof(*fri); |
| 76 | if (! op) |
| 77 | @@ -842,8 +842,8 @@ fuse_strategy_i(struct vnode *vp, struct |
| 78 | fri->fh = fufh->fh_id; |
| 79 | fri->offset = ((off_t)bp->b_blkno) * biosize + ioff; |
| 80 | #if FUSELIB_CONFORM_BIOREAD |
| 81 | - chunksize = min(chunksize, |
| 82 | - min(fri->offset + bp->b_resid, |
| 83 | + chunksize = MIN(chunksize, |
| 84 | + MIN(fri->offset + bp->b_resid, |
| 85 | va.va_size) - fri->offset); |
| 86 | if (chunksize == 0) { |
| 87 | respsize = -1; |
| 88 | @@ -901,7 +901,7 @@ eval: |
| 89 | |
| 90 | bufdat = bp->b_data + bp->b_dirtyoff; |
| 91 | while (bp->b_dirtyend > bp->b_dirtyoff) { |
| 92 | - chunksize = min(bp->b_dirtyend - bp->b_dirtyoff, |
| 93 | + chunksize = MIN(bp->b_dirtyend - bp->b_dirtyoff, |
| 94 | fusefs_get_data(vp->v_mount)->max_write); |
| 95 | |
| 96 | fdi.iosize = sizeof(*fwi); |
