]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
fusefs: correctly handle short writes
authorasomers <asomers@FreeBSD.org>
Thu, 4 Apr 2019 16:51:34 +0000 (16:51 +0000)
committerasomers <asomers@FreeBSD.org>
Thu, 4 Apr 2019 16:51:34 +0000 (16:51 +0000)
commitd02eba0e121602567af37549acba9c6ec7aba3ad
tree2ab9578225b4c236de879ea54995a577750c6be0
parent09d73b9632d8c77fc546a50317d71588e98c25d9
fusefs: correctly handle short writes

If a FUSE daemon returns FOPEN_DIRECT_IO when a file is opened, then it's
allowed to write less data than was requested during a FUSE_WRITE operation
on that file handle.  fusefs should simply return a short write to userland.

The old code attempted to resend the unsent data.  Not only was that
incorrect behavior, but it did it in an ineffective way, by attempting to
"rewind" the uio and uiomove the unsent data again.

This commit correctly handles short writes by returning directly to
userland if FOPEN_DIRECT_IO was set.  If it wasn't set (making the short
write technically a protocol violation), then we resend the unsent data.
But instead of rewinding the uio, just resend the data that's already in the
kernel.

That necessitated a few changes to fuse_ipc.c to reduce the amount of bzero
activity.  fusefs may be marginally faster as a result.

PR: 236381
Sponsored by: The FreeBSD Foundation
sys/fs/fuse/fuse_internal.c
sys/fs/fuse/fuse_io.c
sys/fs/fuse/fuse_ipc.c
sys/fs/fuse/fuse_ipc.h
sys/fs/fuse/fuse_vnops.c
tests/sys/fs/fusefs/mockfs.cc
tests/sys/fs/fusefs/write.cc