On 16/03/2015 14:51, Max Reitz wrote:
>>>
>> Propagating the return value from write_sync is uglier, but it is even
>> better in terms of returned value.
> 
> We can only return -errno values, but write_sync() may do partial writes
> so it may return non-negative values which still indicate an error. So
> we'd have to check whether the return value is negative, if it is,
> return that, if it isn't but if it's still below what we wanted to
> write, return a fixed error (such as -EIO). I'd rather just return -EIO
> and be done with it, but if you really want me to, I can of course do it
> differently.

nbd_wr_sync doesn't do that, it always returns negative errno for a partial
error:

        if (len < 0) {
            err = socket_error();

            /* recoverable error */
            if (err == EINTR || (offset > 0 && (err == EAGAIN || err == 
EWOULDBLOCK))) {
                continue;
            }

            /* unrecoverable error */
            return -err;
        }

The precise error can be useful to distinguish a network error from something
else.  I'm just in doubt about partial reads; those can return a positive error,
in which case you can return ESHUTDOWN (in read_sync).

Paolo

Reply via email to