|
Lines 101-121
__FBSDID("$FreeBSD$");
Link Here
|
| 101 |
|
101 |
|
| 102 |
|
102 |
|
| 103 |
static int |
103 |
static int |
| 104 |
fuse_read_directbackend(struct vnode *vp, struct uio *uio, |
104 |
fuse_read_directbackend(struct vnode *vp, struct uio *uio, |
| 105 |
struct ucred *cred, struct fuse_filehandle *fufh); |
105 |
struct ucred *cred, struct fuse_filehandle *fufh); |
| 106 |
static int |
106 |
static int |
| 107 |
fuse_read_biobackend(struct vnode *vp, struct uio *uio, |
107 |
fuse_read_biobackend(struct vnode *vp, struct uio *uio, |
| 108 |
struct ucred *cred, struct fuse_filehandle *fufh); |
108 |
struct ucred *cred, struct fuse_filehandle *fufh); |
| 109 |
static int |
109 |
static int |
| 110 |
fuse_write_directbackend(struct vnode *vp, struct uio *uio, |
110 |
fuse_write_directbackend(struct vnode *vp, struct uio *uio, |
| 111 |
struct ucred *cred, struct fuse_filehandle *fufh); |
111 |
struct ucred *cred, struct fuse_filehandle *fufh, int ioflag); |
| 112 |
static int |
112 |
static int |
| 113 |
fuse_write_biobackend(struct vnode *vp, struct uio *uio, |
113 |
fuse_write_biobackend(struct vnode *vp, struct uio *uio, |
| 114 |
struct ucred *cred, struct fuse_filehandle *fufh, int ioflag); |
114 |
struct ucred *cred, struct fuse_filehandle *fufh, int ioflag); |
| 115 |
|
115 |
|
| 116 |
int |
116 |
int |
| 117 |
fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, |
117 |
fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, |
| 118 |
struct ucred *cred) |
118 |
struct ucred *cred) |
| 119 |
{ |
119 |
{ |
| 120 |
struct fuse_filehandle *fufh; |
120 |
struct fuse_filehandle *fufh; |
| 121 |
int err, directio; |
121 |
int err, directio; |
|
Lines 149-169
fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag,
Link Here
|
| 149 |
} else { |
149 |
} else { |
| 150 |
FS_DEBUG("buffered read of vnode %ju\n", |
150 |
FS_DEBUG("buffered read of vnode %ju\n", |
| 151 |
(uintmax_t)VTOILLU(vp)); |
151 |
(uintmax_t)VTOILLU(vp)); |
| 152 |
err = fuse_read_biobackend(vp, uio, cred, fufh); |
152 |
err = fuse_read_biobackend(vp, uio, cred, fufh); |
| 153 |
} |
153 |
} |
| 154 |
break; |
154 |
break; |
| 155 |
case UIO_WRITE: |
155 |
case UIO_WRITE: |
| 156 |
if (directio) { |
156 |
if (directio) { |
| 157 |
FS_DEBUG("direct write of vnode %ju via file handle %ju\n", |
157 |
FS_DEBUG("direct write of vnode %ju via file handle %ju\n", |
| 158 |
(uintmax_t)VTOILLU(vp), (uintmax_t)fufh->fh_id); |
158 |
(uintmax_t)VTOILLU(vp), (uintmax_t)fufh->fh_id); |
| 159 |
err = fuse_write_directbackend(vp, uio, cred, fufh); |
159 |
err = fuse_write_directbackend(vp, uio, cred, fufh, ioflag); |
| 160 |
} else { |
160 |
} else { |
| 161 |
FS_DEBUG("buffered write of vnode %ju\n", |
161 |
FS_DEBUG("buffered write of vnode %ju\n", |
| 162 |
(uintmax_t)VTOILLU(vp)); |
162 |
(uintmax_t)VTOILLU(vp)); |
| 163 |
err = fuse_write_biobackend(vp, uio, cred, fufh, ioflag); |
163 |
err = fuse_write_biobackend(vp, uio, cred, fufh, ioflag); |
| 164 |
} |
164 |
} |
| 165 |
break; |
165 |
break; |
| 166 |
default: |
166 |
default: |
| 167 |
panic("uninterpreted mode passed to fuse_io_dispatch"); |
167 |
panic("uninterpreted mode passed to fuse_io_dispatch"); |
| 168 |
} |
168 |
} |
| 169 |
|
169 |
|
|
Lines 311-341
fuse_read_directbackend(struct vnode *vp, struct uio *uio,
Link Here
|
| 311 |
break; |
311 |
break; |
| 312 |
} |
312 |
} |
| 313 |
|
313 |
|
| 314 |
out: |
314 |
out: |
| 315 |
fdisp_destroy(&fdi); |
315 |
fdisp_destroy(&fdi); |
| 316 |
return (err); |
316 |
return (err); |
| 317 |
} |
317 |
} |
| 318 |
|
318 |
|
| 319 |
static int |
319 |
static int |
| 320 |
fuse_write_directbackend(struct vnode *vp, struct uio *uio, |
320 |
fuse_write_directbackend(struct vnode *vp, struct uio *uio, |
| 321 |
struct ucred *cred, struct fuse_filehandle *fufh) |
321 |
struct ucred *cred, struct fuse_filehandle *fufh, int ioflag) |
| 322 |
{ |
322 |
{ |
| 323 |
struct fuse_vnode_data *fvdat = VTOFUD(vp); |
323 |
struct fuse_vnode_data *fvdat = VTOFUD(vp); |
| 324 |
struct fuse_write_in *fwi; |
324 |
struct fuse_write_in *fwi; |
| 325 |
struct fuse_dispatcher fdi; |
325 |
struct fuse_dispatcher fdi; |
| 326 |
size_t chunksize; |
326 |
size_t chunksize; |
| 327 |
int diff; |
327 |
int diff; |
| 328 |
int err = 0; |
328 |
int err = 0; |
| 329 |
|
329 |
|
| 330 |
if (!uio->uio_resid) |
330 |
if (uio->uio_resid == 0) |
| 331 |
return (0); |
331 |
return (0); |
|
|
332 |
if (ioflag & IO_APPEND) |
| 333 |
uio_setoffset(uio, fvdat->filesize); |
| 332 |
|
334 |
|
| 333 |
fdisp_init(&fdi, 0); |
335 |
fdisp_init(&fdi, 0); |
| 334 |
|
336 |
|
| 335 |
while (uio->uio_resid > 0) { |
337 |
while (uio->uio_resid > 0) { |
| 336 |
chunksize = MIN(uio->uio_resid, |
338 |
chunksize = MIN(uio->uio_resid, |
| 337 |
fuse_get_mpdata(vp->v_mount)->max_write); |
339 |
fuse_get_mpdata(vp->v_mount)->max_write); |
| 338 |
|
340 |
|
| 339 |
fdi.iosize = sizeof(*fwi) + chunksize; |
341 |
fdi.iosize = sizeof(*fwi) + chunksize; |
| 340 |
fdisp_make_vp(&fdi, FUSE_WRITE, vp, uio->uio_td, cred); |
342 |
fdisp_make_vp(&fdi, FUSE_WRITE, vp, uio->uio_td, cred); |
| 341 |
|
343 |
|
|
Lines 698-718
fuse_io_strategy(struct vnode *vp, struct buf *bp)
Link Here
|
| 698 |
(off_t)bp->b_blkno * biosize; |
700 |
(off_t)bp->b_blkno * biosize; |
| 699 |
|
701 |
|
| 700 |
if (bp->b_dirtyend > bp->b_dirtyoff) { |
702 |
if (bp->b_dirtyend > bp->b_dirtyoff) { |
| 701 |
io.iov_len = uiop->uio_resid = bp->b_dirtyend |
703 |
io.iov_len = uiop->uio_resid = bp->b_dirtyend |
| 702 |
- bp->b_dirtyoff; |
704 |
- bp->b_dirtyoff; |
| 703 |
uiop->uio_offset = (off_t)bp->b_blkno * biosize |
705 |
uiop->uio_offset = (off_t)bp->b_blkno * biosize |
| 704 |
+ bp->b_dirtyoff; |
706 |
+ bp->b_dirtyoff; |
| 705 |
io.iov_base = (char *)bp->b_data + bp->b_dirtyoff; |
707 |
io.iov_base = (char *)bp->b_data + bp->b_dirtyoff; |
| 706 |
uiop->uio_rw = UIO_WRITE; |
708 |
uiop->uio_rw = UIO_WRITE; |
| 707 |
|
709 |
|
| 708 |
error = fuse_write_directbackend(vp, uiop, cred, fufh); |
710 |
error = fuse_write_directbackend(vp, uiop, cred, fufh, 0); |
| 709 |
|
711 |
|
| 710 |
if (error == EINTR || error == ETIMEDOUT |
712 |
if (error == EINTR || error == ETIMEDOUT |
| 711 |
|| (!error && (bp->b_flags & B_NEEDCOMMIT))) { |
713 |
|| (!error && (bp->b_flags & B_NEEDCOMMIT))) { |
| 712 |
|
714 |
|
| 713 |
bp->b_flags &= ~(B_INVAL | B_NOCACHE); |
715 |
bp->b_flags &= ~(B_INVAL | B_NOCACHE); |
| 714 |
if ((bp->b_flags & B_PAGING) == 0) { |
716 |
if ((bp->b_flags & B_PAGING) == 0) { |
| 715 |
bdirty(bp); |
717 |
bdirty(bp); |
| 716 |
bp->b_flags &= ~B_DONE; |
718 |
bp->b_flags &= ~B_DONE; |
| 717 |
} |
719 |
} |
| 718 |
if ((error == EINTR || error == ETIMEDOUT) && |
720 |
if ((error == EINTR || error == ETIMEDOUT) && |