From: Peter Lieven <pl@kamp.de>
To: Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
ronnie sahlberg <ronniesahlberg@gmail.com>,
qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-stable] Recent patches for 2.4
Date: Tue, 04 Aug 2015 14:53:13 +0200 [thread overview]
Message-ID: <55C0B5B9.4040001@kamp.de> (raw)
In-Reply-To: <55C0B03D.8000109@kamp.de>
Am 04.08.2015 um 14:29 schrieb Peter Lieven:
> Am 04.08.2015 um 14:09 schrieb Paolo Bonzini:
>>
>> On 04/08/2015 13:57, Peter Lieven wrote:
>>> Okay, what I found out is that in aio_poll I get revents = POLLIN for
>>> the nfs file descriptor. But there is no data available on the socket.
>> Does read return 0 or EAGAIN?
>>
>> If it returns EAGAIN, the bug is in the QEMU main loop or the kernel.
>> It should never happen that poll returns POLLIN and read returns EAGAIN.
>>
>> If it returns 0, it means the other side called shutdown(fd, SHUT_WR).
>> Then I think the bug is in the libnfs driver or more likely libnfs. You
>> should stop polling the POLLIN event after read has returned 0 once.
>
> You might be right. Ronnie originally used the FIONREAD ioctl before every read and considered
> the socket as disconnected if the available bytes returned where 0.
> I found that I get available bytes == 0 from that ioctl even if the socket was not closed.
> This seems to be some kind of bug in Linux - at least what I have thought.
>
> See BUGS in the select(2) manpage.
>
> Under Linux, select() may report a socket file descriptor as "ready for reading", while nevertheless a subsequent read blocks. This could for example happen when data has arrived but
> upon examination has wrong checksum and is discarded. There may be other circumstances in which a file descriptor is spuriously reported as ready. Thus it may be safer to use O_NON‐
> BLOCK on sockets that should not block.
>
> I will debug further, but it seems to be that I receive a POLLIN even if there is no data available. I see 0 bytes from the recv call inside libnfs and continue without a deadlock - at least
> so far.
>
> Would it be a good idea to count the number of 0 bytes from recv and react after I received 0 bytes for a number of consecutive times?
>
> And then: stop polling POLLIN or reconnect?
Okay, got it. Ronnie was using FIONREAD without checking for EAGAIN or EINTR.
I will send a patch for libnfs to reconnect if count == 0. Libiscsi is not affected, it reconnects if count is 0.
Peter
next prev parent reply other threads:[~2015-08-04 12:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 8:12 [Qemu-devel] Recent patches for 2.4 Peter Lieven
2015-07-31 8:22 ` Paolo Bonzini
2015-07-31 8:35 ` Peter Lieven
2015-07-31 9:29 ` Paolo Bonzini
2015-08-04 9:22 ` [Qemu-devel] [Qemu-stable] " Peter Lieven
2015-08-04 11:53 ` Paolo Bonzini
2015-08-04 11:57 ` Peter Lieven
2015-08-04 12:09 ` Paolo Bonzini
2015-08-04 12:29 ` Peter Lieven
2015-08-04 12:53 ` Peter Lieven [this message]
2015-08-04 23:23 ` ronnie sahlberg
2015-08-05 8:39 ` Paolo Bonzini
2015-08-06 7:51 ` Peter Lieven
2015-09-03 13:11 ` Peter Lieven
2015-09-07 16:28 ` Paolo Bonzini
2015-09-07 19:11 ` Peter Lieven
2015-09-07 19:14 ` Paolo Bonzini
2015-09-07 21:05 ` Peter Lieven
2015-09-21 7:40 ` Peter Lieven
2015-09-21 9:41 ` Paolo Bonzini
2015-09-21 9:52 ` Peter Lieven
2015-09-21 12:16 ` Paolo Bonzini
2015-08-04 18:20 ` Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55C0B5B9.4040001@kamp.de \
--to=pl@kamp.de \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=ronniesahlberg@gmail.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).