FUSE: Only "dirty" cached file size when data is dirty

Most users of fuse_vnode_setsize() set the cached fvdat->filesize and update
the buf cache bounds as a result of either a read from the underlying FUSE
filesystem, or as part of a write-through type operation (like truncate =>
VOP_SETATTR).  In these cases, do not set the FN_SIZECHANGE flag, which
indicates that an inode's data is dirty (in particular, that the local buf
cache and fvdat->filesize have dirty extended data).

PR:		230258 (related)
This commit is contained in:
Conrad Meyer 2019-02-15 22:51:09 +00:00
parent 09176f096b
commit 194e691aaf
3 changed files with 8 additions and 3 deletions

View File

@ -362,8 +362,11 @@ fuse_write_directbackend(struct vnode *vp, struct uio *uio,
}
uio->uio_resid += diff;
uio->uio_offset -= diff;
if (uio->uio_offset > fvdat->filesize)
if (uio->uio_offset > fvdat->filesize &&
fuse_data_cache_enable) {
fuse_vnode_setsize(vp, cred, uio->uio_offset);
fvdat->flag &= ~FN_SIZECHANGE;
}
}
fdisp_destroy(&fdi);

View File

@ -375,6 +375,7 @@ fuse_vnode_refreshsize(struct vnode *vp, struct ucred *cred)
struct vattr va;
if ((fvdat->flag & FN_SIZECHANGE) != 0 ||
fuse_data_cache_enable == 0 ||
(fuse_refresh_size == 0 && fvdat->filesize != 0))
return;

View File

@ -538,6 +538,7 @@ fuse_vnop_getattr(struct vop_getattr_args *ap)
if (fvdat->filesize != new_filesize) {
fuse_vnode_setsize(vp, cred, new_filesize);
fvdat->flag &= ~FN_SIZECHANGE;
}
}
debug_printf("fuse_getattr e: returning 0\n");
@ -1637,9 +1638,9 @@ fuse_vnop_setattr(struct vop_setattr_args *ap)
err = EAGAIN;
}
}
if (!err && !sizechanged) {
if (err == 0)
cache_attrs(vp, (struct fuse_attr_out *)fdi.answ, NULL);
}
out:
fdisp_destroy(&fdi);
if (!err && sizechanged) {