[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 05/25] nbd: Avoid generic -EINVAL

From: Paolo Bonzini
Subject: Re: [Qemu-block] [PATCH 05/25] nbd: Avoid generic -EINVAL
Date: Mon, 16 Mar 2015 15:42:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

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

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

            /* recoverable error */
            if (err == EINTR || (offset > 0 && (err == EAGAIN || err == 

            /* 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).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]