From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNFxg-0002r7-Eh for qemu-devel@nongnu.org; Thu, 06 Aug 2015 03:51:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNFxc-0003Ni-83 for qemu-devel@nongnu.org; Thu, 06 Aug 2015 03:51:36 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:53753 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNFxb-0003MY-Sr for qemu-devel@nongnu.org; Thu, 06 Aug 2015 03:51:32 -0400 Message-ID: <55C311F9.7040800@kamp.de> Date: Thu, 06 Aug 2015 09:51:21 +0200 From: Peter Lieven MIME-Version: 1.0 References: <55BB2DF7.8010808@kamp.de> <55BB302D.50108@redhat.com> <55BB335A.1010009@kamp.de> <55BB3FE7.3000106@redhat.com> <55C08461.1040308@kamp.de> <55C0A7AA.70609@redhat.com> <55C0A88D.1010800@kamp.de> <55C0AB81.8020404@redhat.com> <55C0B03D.8000109@kamp.de> <55C0B5B9.4040001@kamp.de> <55C1CBDA.6050803@redhat.com> In-Reply-To: <55C1CBDA.6050803@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-stable] Recent patches for 2.4 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , ronnie sahlberg Cc: "qemu-devel@nongnu.org" , Stefan Hajnoczi , qemu-stable@nongnu.org Am 05.08.2015 um 10:39 schrieb Paolo Bonzini: > > On 05/08/2015 01:23, ronnie sahlberg wrote: >> You only get >0 from this call if there are actual bytes available to read. >> >> For context, the problem was that >> >> >> 75 static void nfs_process_read(void *arg) >> 76 { >> 77 NFSClient *client = arg; >> 78 nfs_service(client->context, POLLIN); >> 79 nfs_set_events(client); >> 80 } >> >> sometimes trigger and call nfs_service(POLLIN) eventhough the socket is >> not readable. > Does read() return -1/EAGAIN or 0? > > If it returns 0, then this is expected: it means that the other side has > shutdown the socket's write-side. libnfs should either reconnect, or > disable POLLIN, treat all pending operations as aborted and stop > submitting more. I also went on reproducing and can confirm, that I see FIONREAD return 0 bytes available when booting a CDROM in Qemu with libnfs before commit cf420d3 (socket: use FIONREAD ioctl only for UDP). But a lot has changed in rpc_read_from_socket in libnfs since we dropped FIONREAD. Most importantly we changed from recv without flags to recv with MSG_DONTWAIT. And with current master I never receive spurious readiness any more. So there is nothing we need to fix here except from handling recv return 0 bytes and then reconnect. This fix is already in the current master of libnfs. And this solves the deadlock in qemu-img I have observed. Thanks for you help, Peter