Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/fuse/fuse_node.c
Show First 20 Lines • Show All 383 Lines • ▼ Show 20 Lines | fuse_vnode_savesize(struct vnode *vp, struct ucred *cred, pid_t pid) | ||||
fdisp_destroy(&fdi); | fdisp_destroy(&fdi); | ||||
if (err == 0) | if (err == 0) | ||||
fvdat->flag &= ~FN_SIZECHANGE; | fvdat->flag &= ~FN_SIZECHANGE; | ||||
return err; | return err; | ||||
} | } | ||||
/* | /* | ||||
* Adjust the vnode's size to a new value, such as that provided by | * Adjust the vnode's size to a new value. | ||||
* FUSE_GETATTR. | * | ||||
* If the new value came from the server, such as from a FUSE_GETATTR | |||||
* operation, set `from_server` true. But if it came from a local operation, | |||||
* such as write(2) or truncate(2), set `from_server` false. | |||||
*/ | */ | ||||
int | int | ||||
fuse_vnode_setsize(struct vnode *vp, off_t newsize) | fuse_vnode_setsize(struct vnode *vp, off_t newsize, bool from_server) | ||||
{ | { | ||||
struct fuse_vnode_data *fvdat = VTOFUD(vp); | struct fuse_vnode_data *fvdat = VTOFUD(vp); | ||||
struct vattr *attrs; | struct vattr *attrs; | ||||
off_t oldsize; | off_t oldsize; | ||||
size_t iosize; | size_t iosize; | ||||
struct buf *bp = NULL; | struct buf *bp = NULL; | ||||
int err = 0; | int err = 0; | ||||
Show All 24 Lines | if (!bp) { | ||||
err = EINTR; | err = EINTR; | ||||
goto out; | goto out; | ||||
} | } | ||||
if (!(bp->b_flags & B_CACHE)) | if (!(bp->b_flags & B_CACHE)) | ||||
goto out; /* Nothing to do */ | goto out; /* Nothing to do */ | ||||
MPASS(bp->b_flags & B_VMIO); | MPASS(bp->b_flags & B_VMIO); | ||||
vfs_bio_clrbuf(bp); | vfs_bio_clrbuf(bp); | ||||
bp->b_dirtyend = MIN(bp->b_dirtyend, newsize - lbn * iosize); | bp->b_dirtyend = MIN(bp->b_dirtyend, newsize - lbn * iosize); | ||||
} else if (from_server && newsize > oldsize && oldsize != VNOVAL) { | |||||
/* | |||||
* The FUSE server changed the file size behind our back. We | |||||
* should invalidate the entire cache. | |||||
*/ | |||||
daddr_t left_lbn, end_lbn; | |||||
left_lbn = oldsize / iosize; | |||||
end_lbn = howmany(newsize, iosize); | |||||
v_inval_buf_range(vp, 0, end_lbn, iosize); | |||||
} | } | ||||
out: | out: | ||||
if (bp) | if (bp) | ||||
brelse(bp); | brelse(bp); | ||||
vnode_pager_setsize(vp, newsize); | vnode_pager_setsize(vp, newsize); | ||||
return err; | return err; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |