qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	John Snow <jsnow@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
	"open list:Network Block Dev..." <qemu-block@nongnu.org>,
	Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: Re: deadlock when using iothread during backup_clean()
Date: Tue, 5 Sep 2023 13:25:40 +0200	[thread overview]
Message-ID: <6387bfcd-3161-a016-b69b-9da4b1fb18c1@proxmox.com> (raw)
In-Reply-To: <bcbd48da-e4cc-f9c9-000c-6a9f98ca156f@proxmox.com>

Am 05.09.23 um 12:01 schrieb Fiona Ebner:
> 
> Can we assume block_job_remove_all_bdrv() to always hold the job's
> AioContext? And if yes, can we just tell bdrv_graph_wrlock() that it
> needs to release that before polling to fix the deadlock?
> 

I tried a doing something similar as a proof-of-concept

> diff --git a/blockjob.c b/blockjob.c
> index 58c5d64539..1a696241a0 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -198,19 +198,19 @@ void block_job_remove_all_bdrv(BlockJob *job)
>       * one to make sure that such a concurrent access does not attempt
>       * to process an already freed BdrvChild.
>       */
> -    bdrv_graph_wrlock(NULL);
>      while (job->nodes) {
>          GSList *l = job->nodes;
>          BdrvChild *c = l->data;
>  
>          job->nodes = l->next;
>  
> +        bdrv_graph_wrlock(c->bs);
>          bdrv_op_unblock_all(c->bs, job->blocker);
>          bdrv_root_unref_child(c);
> +        bdrv_graph_wrunlock();
>  
>          g_slist_free_1(l);
>      }
> -    bdrv_graph_wrunlock();
>  }

and while it did get slightly further, I ran into another deadlock with

> #0  0x00007f1941155136 in __ppoll (fds=0x55992068fb20, nfds=2, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:42
> #1  0x000055991c6a1a3f in qemu_poll_ns (fds=0x55992068fb20, nfds=2, timeout=-1) at ../util/qemu-timer.c:339
> #2  0x000055991c67ed6c in fdmon_poll_wait (ctx=0x55991f058810, ready_list=0x7ffda8c987b0, timeout=-1) at ../util/fdmon-poll.c:79
> #3  0x000055991c67e6a8 in aio_poll (ctx=0x55991f058810, blocking=true) at ../util/aio-posix.c:670
> #4  0x000055991c50a763 in bdrv_graph_wrlock (bs=0x0) at ../block/graph-lock.c:145
> #5  0x000055991c4daf85 in bdrv_close (bs=0x55991fff2f30) at ../block.c:5166
> #6  0x000055991c4dc050 in bdrv_delete (bs=0x55991fff2f30) at ../block.c:5606
> #7  0x000055991c4df205 in bdrv_unref (bs=0x55991fff2f30) at ../block.c:7173
> #8  0x000055991c4fb8ca in bdrv_cbw_drop (bs=0x55991fff2f30) at ../block/copy-before-write.c:566
> #9  0x000055991c4f9685 in backup_clean (job=0x55992016d0b0) at ../block/backup.c:105



  reply	other threads:[~2023-09-05 11:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 10:01 deadlock when using iothread during backup_clean() Fiona Ebner
2023-09-05 11:25 ` Fiona Ebner [this message]
2023-10-04 16:51   ` Vladimir Sementsov-Ogievskiy
2023-09-05 11:42 ` Paolo Bonzini
2023-09-28  8:06   ` Fiona Ebner
2023-10-04 17:08     ` Vladimir Sementsov-Ogievskiy
2023-10-06 12:18       ` Fiona Ebner
2023-10-17 10:18         ` Fiona Ebner
2023-10-17 12:12           ` Kevin Wolf
2023-10-17 13:37             ` Fiona Ebner
2023-10-17 14:20               ` Kevin Wolf
2023-10-18  9:42                 ` Fiona Ebner
2023-10-19 12:14                   ` Kevin Wolf
2023-10-19 13:53                     ` Fiona Ebner
2023-10-20 13:52                       ` Fiona Ebner
2023-11-03 13:20                         ` Fiona Ebner

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=6387bfcd-3161-a016-b69b-9da4b1fb18c1@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=t.lamprecht@proxmox.com \
    --cc=vsementsov@yandex-team.ru \
    /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).