Mike Snitzer wrote:
> How does one do a zero-length read or write? I've been testing
> various userspace methods to detect the nbd-client's connection to be
> hung (TCP timeout). Using dd is unreliable because the read request
> is fulfilled from cache if you don't use O_DIRECT.
>
> If we could do a zero-length write then this would very easily
> excercise the nbd connection without any protocol change or O_DIRECT
> reads. Can you elaborate on what is needed for reliable zero-length
> writes? The 'man 2 write' states:
> "If count is zero and the file descriptor refers to a regular file, 0
> may be returned, or an error could be detected. For a special file,
> the results are not portable."
I don't know that there is a way to do it from user level. But a minor
tweak to the driver would allow a user level process or the nbd-client
itself to do this. And the basic protocol wouldn't change and hopefully
the server wouldn't have to be modified either -- but that depends on
how it's implemented.