fuse(4): add dtrace probe for illegal short writes

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-03-08 02:00:49 +00:00
parent c2e7dba7f8
commit 84c4fd1f48
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=344914

View File

@ -369,13 +369,24 @@ fuse_write_directbackend(struct vnode *vp, struct uio *uio,
if ((err = fdisp_wait_answ(&fdi)))
break;
/* Adjust the uio in the case of short writes */
diff = chunksize - ((struct fuse_write_out *)fdi.answ)->size;
if (diff < 0) {
err = EINVAL;
break;
} else if (diff > 0 && !(ioflag & IO_DIRECT)) {
/*
* XXX We really should be directly checking whether
* the file was opened with FOPEN_DIRECT_IO, not
* IO_DIRECT. IO_DIRECT can be set in multiple ways.
*/
SDT_PROBE2(fuse, , io, trace, 1,
"misbehaving filesystem: short writes are only "
"allowed with direct_io");
}
uio->uio_resid += diff;
uio->uio_offset -= diff;
if (uio->uio_offset > fvdat->filesize &&
fuse_data_cache_mode != FUSE_CACHE_UC) {
fuse_vnode_setsize(vp, cred, uio->uio_offset);