From: Stefan Hajnoczi <stefanha@gmail.com>
To: Eric Blake <eblake@redhat.com>
Cc: "Fangyi (C)" <eric.fangyi@huawei.com>,
kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com,
lina.lulina@huawei.com, qemu-block@nongnu.org, subo7@huawei.com,
qemu-devel@nongnu.org, wu.wubin@huawei.com,
"jiangxiaoqing (C)" <sochin.jiang@huawei.com>
Subject: Re: [Qemu-devel] [Qemu-block] NBD handshake may block qemu main thread when socket delays or has packet loss
Date: Thu, 12 Jan 2017 14:40:06 +0000 [thread overview]
Message-ID: <20170112144006.GE14042@stefanha-x1.localdomain> (raw)
In-Reply-To: <c7c4fd91-1374-7371-1ff9-533a8e916f2a@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]
On Wed, Jan 04, 2017 at 02:44:53PM -0600, Eric Blake wrote:
> On 01/04/2017 02:45 AM, Fangyi (C) wrote:
> > As we all know, socket is in blocking mode when nbd is negotiating
> > with the other end. If the network is poor because of delay or packet
> > loss, socket read or write will return very slowly. The mainloop events
> > won't be handled in time util nbd handshake ends.
>
> I wonder if Paolo's work to improve NBD coroutine usage after handshakes
> can be leveraged here?
>
> https://lists.gnu.org/archive/html/qemu-devel/2016-12/msg03224.html
>
> >
> > Any advices to solve the problem?
>
> At any rate, it sounds like someone will have to patch NBD code to use
> coroutines instead of blocking for the handshake portion (and that's
> true in general - ANY operation that can block should probably be
> refactored into aio or coroutines so that the main loop can remain
> responsive).
This is a general issue with network block drivers. They tend to do
blocking DNS resolution, blocking connection, and blocking protocol
handshake/negotiation in .bdrv_open().
We cannot expose a block device to the guest before it has been opened
because the disk's capacity is unknown plus the guest would experience
I/O timeouts or errors.
I think we need to agree on how to handle this for all different types
of network protocols, not just nbd, before code can be written.
One starting point is:
Should we make .drv_open() a coroutine and introduce a async concept to
blockdev_add, reopen, etc?
The BlockDriverState would be in a special OPENING or OFFLINE state
where its name is reserved but it cannot be used for I/O or emulated
devices yet.
QMP clients would have watch out for an event that tells them that it's
now okay to device-add the emulated storage device using the drive.
Any ideas for a nicer solution?
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
prev parent reply other threads:[~2017-01-12 14:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-04 8:45 [Qemu-devel] NBD handshake may block qemu main thread when socket delays or has packet loss Fangyi (C)
2017-01-04 20:44 ` Eric Blake
2017-01-12 14:40 ` Stefan Hajnoczi [this message]
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=20170112144006.GE14042@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=eblake@redhat.com \
--cc=eric.fangyi@huawei.com \
--cc=kwolf@redhat.com \
--cc=lina.lulina@huawei.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sochin.jiang@huawei.com \
--cc=subo7@huawei.com \
--cc=wu.wubin@huawei.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).