From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/2] block: Forbid bdrv_set_aio_context outside BQL
Date: Sun, 15 Feb 2015 10:40:51 +0800 [thread overview]
Message-ID: <1423968052-17461-2-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1423968052-17461-1-git-send-email-famz@redhat.com>
Even if the caller has the old #AioContext, there can be a deadlock, due
to the leading bdrv_drain_all:
Suppose there are three io threads (a, b, c) with each owning a BDS
(bds_a, bds_b, bds_c), and a and b want to move their own BDS to c at
the same time:
iothread a iothread b
--------------------------------------------------------------------------
bdrv_set_aio_context(bds_a, c) bdrv_set_aio_context(bds_b, c)
-> bdrv_drain_all() -> bdrv_drain_all()
-> acquire a (OK, already has) -> acquire a (blocked)
-> acquire b (blocked) -> acquire b
-> acquire c -> acquire c
Current caller of bdrv_set_aio_context outside BQL is
virtio-scsi-dataplane, which will be fixed in the next patches.
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/block/block.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/block/block.h b/include/block/block.h
index 321295e..4fce25d 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -546,8 +546,7 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs);
* Changes the #AioContext used for fd handlers, timers, and BHs by this
* BlockDriverState and all its children.
*
- * This function must be called from the old #AioContext or with a lock held so
- * the old #AioContext is not executing.
+ * This function must be called with iothread lock held.
*/
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context);
--
2.1.0
next prev parent reply other threads:[~2015-02-15 2:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-15 2:40 [Qemu-devel] [PATCH v2 0/2] block, virtio-scsi: Fix blk_set_aio_context Fam Zheng
2015-02-15 2:40 ` Fam Zheng [this message]
2015-02-15 3:05 ` [Qemu-devel] [PATCH v2 1/2] block: Forbid bdrv_set_aio_context outside BQL Fam Zheng
2015-02-15 2:40 ` [Qemu-devel] [PATCH v2 2/2] virtio-scsi-dataplane: Call blk_set_aio_context within BQL Fam Zheng
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=1423968052-17461-2-git-send-email-famz@redhat.com \
--to=famz@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).