From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXWER-0008K0-MP for qemu-devel@nongnu.org; Mon, 16 Mar 2015 10:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXWEN-0005o3-Pm for qemu-devel@nongnu.org; Mon, 16 Mar 2015 10:43:03 -0400 Message-ID: <5506EBE9.7070309@redhat.com> Date: Mon, 16 Mar 2015 15:42:49 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1424887718-10800-1-git-send-email-mreitz@redhat.com> <1424887718-10800-6-git-send-email-mreitz@redhat.com> <55002568.2070201@redhat.com> <5506DFE3.2000104@redhat.com> In-Reply-To: <5506DFE3.2000104@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 05/25] nbd: Avoid generic -EINVAL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-block@nongnu.org Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi 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