From: Kevin Wolf <kwolf@redhat.com>
To: John Levon <levon@movementarian.org>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
Hanna Czenczek <hreitz@redhat.com>,
Fiona Ebner <f.ebner@proxmox.com>, John Snow <jsnow@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: Deadlock with SATA CD I/O and eject
Date: Tue, 19 Sep 2023 16:03:57 +0200 [thread overview]
Message-ID: <ZQmqTefqVHTBb3y+@redhat.com> (raw)
In-Reply-To: <ZQmaqorH9YqNG1+g@movementarian.org>
Am 19.09.2023 um 14:57 hat John Levon geschrieben:
> On Tue, Sep 19, 2023 at 12:54:59PM +0200, Kevin Wolf wrote:
>
> > > In the meantime, we start processing the blk_drain() code, so by the time this
> > > blk_pread() actually gets handled, quiesce is set, and we get stuck in the
> > > blk_wait_while_drained().
> > >
> > > I don't know the qemu block stack well enough to propose an actual fix.
> > >
> > > Experimentally, waiting for ->in_flight to drop to zero *before* we quiesce in
> > > blk_remove_bs() via an AIO_WAIT_WHILE() avoids the symptom, but I'm pretty sure
> > > that's just a band-aid instead of fixing the deadlock.
> >
> > Related discussion: https://lists.gnu.org/archive/html/qemu-block/2023-03/msg00284.html
> >
> > Actually, it seems we never fixed that problem either?
> >
> > Back then I suggested that blk_drain*() should disable request queuing
> > because its callers don't want to quiesce the BlockBackend, but rather
> > get their own requests completed. I think this approach would solve this
> > one as well.
>
> In this case though, it's not their own requests right? We have incoming I/O
> from the guest and the eject is a separate operation.
It's not the same code path, but we're operating in the context of the
IDE device (or more specifically, its BlockBackend), so in that sense it
is "its own requests".
The main difference is anyway between just stopping activity (even if
it's in the middle of a higher level operation of the device) and
getting requests fully completed. We want the latter here.
> So why it would be OK to disable queuing and have ongoing I/Os (i.e.
> blk->in_flight > 0) racing against the block remove?
With eject, the case is simple for IDE: We hold the BQL, so the guest
won't be able to submit new requests anyway.
In more complicated cases like virtio-blk, bdrv_drained_begin() and
friends take care to stop new requests from coming in from the guest by
not running notifiers while the device is drained.
We just need to take care of the requests that have already started.
> > Your experiment with moving the queuing later is basically what Paolo
>
> I think it's much more flaky than that, isn't it? It's just clearing out the
> *current* pending queue, but nothing would stop new I/Os from being started
> before we dropped into the poll for blk->in_flight to be zero again. In my case,
> this just happens to work because the prior tray open notification has stopped
> new I/O being filed, right?
I think it's the same as above, holding the BQL and calling drain would
already take care of that.
Kevin
prev parent reply other threads:[~2023-09-19 14:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 17:28 Deadlock with SATA CD I/O and eject John Levon
2023-09-19 10:54 ` Kevin Wolf
2023-09-19 11:23 ` Hanna Czenczek
2023-09-19 12:57 ` John Levon
2023-09-19 14:03 ` Kevin Wolf [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=ZQmqTefqVHTBb3y+@redhat.com \
--to=kwolf@redhat.com \
--cc=f.ebner@proxmox.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=levon@movementarian.org \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).