From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: Hanna Czenczek <hreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Eric Blake <eblake@redhat.com>, Fiona Ebner <f.ebner@proxmox.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Denis V. Lunev" <den@virtuozzo.com>,
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Subject: Re: [BUG, RFC] Block graph deadlock on job-dismiss
Date: Mon, 28 Apr 2025 17:34:54 +0300 [thread overview]
Message-ID: <4a384d72-fae7-4b83-acfb-7b8abaf21de7@virtuozzo.com> (raw)
In-Reply-To: <73839c04-7616-407e-b057-80ca69e63f51@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 2067 bytes --]
On 4/24/25 8:32 PM, Andrey Drobyshev wrote:
> Hi all,
>
> There's a bug in block layer which leads to block graph deadlock.
> Notably, it takes place when blockdev IO is processed within a separate
> iothread.
>
> This was initially caught by our tests, and I was able to reduce it to a
> relatively simple reproducer. Such deadlocks are probably supposed to
> be covered in iotests/graph-changes-while-io, but this deadlock isn't.
>
> Basically what the reproducer does is launches QEMU with a drive having
> 'iothread' option set, creates a chain of 2 snapshots, launches
> block-commit job for a snapshot and then dismisses the job, starting
> from the lower snapshot. If the guest is issuing IO at the same time,
> there's a race in acquiring block graph lock and a potential deadlock.
>
> Here's how it can be reproduced:
>
> [...]
>
I took a closer look at iotests/graph-changes-while-io, and have managed
to reproduce the same deadlock in a much simpler setup, without a guest.
1. Run QSD:> ./build/storage-daemon/qemu-storage-daemon --object
iothread,id=iothread0 \
> --blockdev null-co,node-name=node0,read-zeroes=true \
> --nbd-server addr.type=unix,addr.path=/var/run/qsd_nbd.sock \
> --export nbd,id=exp0,node-name=node0,iothread=iothread0,fixed-iothread=true,writable=true \
> --chardev socket,id=qmp-sock,path=/var/run/qsd_qmp.sock,server=on,wait=off \
> --monitor chardev=qmp-sock
2. Launch IO:
> qemu-img bench -f raw -c 2000000 'nbd+unix:///node0?socket=/var/run/qsd_nbd.sock'
3. Add 2 snapshots and remove lower one (script attached):> while
/bin/true ; do ./rls_qsd.sh ; done
And then it hangs.
I'll also send a patch with corresponding test case added directly to
iotests.
This reproduce seems to be hanging starting from Fiona's commit
67446e605dc ("blockjob: drop AioContext lock before calling
bdrv_graph_wrlock()"). AioContext locks were dropped entirely later on
in Stefan's commit b49f4755c7 ("block: remove AioContext locking"), but
the problem remains.
Andrey
[-- Attachment #2: rls_qsd.sh --]
[-- Type: application/x-shellscript, Size: 1755 bytes --]
next prev parent reply other threads:[~2025-04-28 14:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 17:32 [BUG, RFC] Block graph deadlock on job-dismiss Andrey Drobyshev
2025-04-28 14:34 ` Andrey Drobyshev [this message]
2025-04-28 14:46 ` [RFC PATCH 1/1] iotests/graph-changes-while-io: add test case with removal of lower snapshot andrey.drobyshev
2025-04-30 8:47 ` [BUG, RFC] Block graph deadlock on job-dismiss Fiona Ebner
2025-04-30 14:03 ` Andrey Drobyshev
2025-04-30 18:50 ` Stefan Hajnoczi
2025-05-02 17:34 ` Kevin Wolf
2025-05-02 17:52 ` Denis V. Lunev
2025-05-02 21:50 ` Kevin Wolf
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=4a384d72-fae7-4b83-acfb-7b8abaf21de7@virtuozzo.com \
--to=andrey.drobyshev@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=f.ebner@proxmox.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--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).