> So, when the fs daemon tries to send back a short read, then the kernel
> silently relaxes this and fills up the missing part with zeroes (at least, if
> the top of the to-be-read range doesn't exceed file size); when the daemon
> tries to send back a short write, the kernel paranoidly returns with error.
> Is it the intended behaviour?
It's documented in <fuse.h> and other places.
> This at least seems counter-intuitive for
> me. I'd naively expect that the kernel either
> (a) stops I/O when less data is transferred than the I/O size
> (b) retries until the I/O size is reached cumulatively, or the daemon responds
> with error or 0 sized I/O.
> Moreover, I'd expect that the chosen strategy is same for reading and writing.
Strategy (a) doesn't work with the page cache. Strategy (b) is trivial
to do in the filesystem itself, basically that's the reason why it
wasn't implemented in the kernel.
> (Btw, I do see the (a) type behaviour with direct_io.)
Yes, direct_io bypasses the page cache, so (a) can be made to work.
It's one of the reasons for using direct_io.