From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
Emanuele Giuseppe Esposito <eesposit@redhat.com>,
qemu-devel@nongnu.org, Hanna Reitz <hreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [RFC PATCH 3/6] block/io.c: introduce bdrv_subtree_drained_{begin/end}_unlocked
Date: Mon, 13 Dec 2021 05:40:11 -0500 [thread overview]
Message-ID: <20211213104014.69858-4-eesposit@redhat.com> (raw)
In-Reply-To: <20211213104014.69858-1-eesposit@redhat.com>
Same as the locked version, but use BDRV_POLL_UNLOCKED
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block/io.c | 35 ++++++++++++++++++++++++++---------
include/block/block-io.h | 2 ++
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/block/io.c b/block/io.c
index 3be08cad29..a031691860 100644
--- a/block/io.c
+++ b/block/io.c
@@ -334,7 +334,7 @@ static bool bdrv_drain_poll_top_level(BlockDriverState *bs, bool recursive,
static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
BdrvChild *parent, bool ignore_bds_parents,
- bool poll);
+ bool poll, bool unlock);
static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
BdrvChild *parent, bool ignore_bds_parents,
int *drained_end_counter);
@@ -352,7 +352,7 @@ static void bdrv_co_drain_bh_cb(void *opaque)
if (data->begin) {
assert(!data->drained_end_counter);
bdrv_do_drained_begin(bs, data->recursive, data->parent,
- data->ignore_bds_parents, data->poll);
+ data->ignore_bds_parents, data->poll, false);
} else {
assert(!data->poll);
bdrv_do_drained_end(bs, data->recursive, data->parent,
@@ -441,7 +441,7 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
BdrvChild *parent, bool ignore_bds_parents,
- bool poll)
+ bool poll, bool unlock)
{
BdrvChild *child, *next;
@@ -458,7 +458,7 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
bs->recursive_quiesce_counter++;
QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
bdrv_do_drained_begin(child->bs, true, child, ignore_bds_parents,
- false);
+ false, false);
}
}
@@ -473,18 +473,28 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
*/
if (poll) {
assert(!ignore_bds_parents);
- BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, recursive, parent));
+ if (unlock) {
+ BDRV_POLL_WHILE_UNLOCKED(bs,
+ bdrv_drain_poll_top_level(bs, recursive, parent));
+ } else {
+ BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, recursive, parent));
+ }
}
}
void bdrv_drained_begin(BlockDriverState *bs)
{
- bdrv_do_drained_begin(bs, false, NULL, false, true);
+ bdrv_do_drained_begin(bs, false, NULL, false, true, false);
}
void bdrv_subtree_drained_begin(BlockDriverState *bs)
{
- bdrv_do_drained_begin(bs, true, NULL, false, true);
+ bdrv_do_drained_begin(bs, true, NULL, false, true, false);
+}
+
+void bdrv_subtree_drained_begin_unlocked(BlockDriverState *bs)
+{
+ bdrv_do_drained_begin(bs, true, NULL, false, true, true);
}
/**
@@ -556,12 +566,19 @@ void bdrv_subtree_drained_end(BlockDriverState *bs)
BDRV_POLL_WHILE(bs, qatomic_read(&drained_end_counter) > 0);
}
+void bdrv_subtree_drained_end_unlocked(BlockDriverState *bs)
+{
+ int drained_end_counter = 0;
+ bdrv_do_drained_end(bs, true, NULL, false, &drained_end_counter);
+ BDRV_POLL_WHILE_UNLOCKED(bs, qatomic_read(&drained_end_counter) > 0);
+}
+
void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent)
{
int i;
for (i = 0; i < new_parent->recursive_quiesce_counter; i++) {
- bdrv_do_drained_begin(child->bs, true, child, false, true);
+ bdrv_do_drained_begin(child->bs, true, child, false, true, false);
}
}
@@ -671,7 +688,7 @@ void bdrv_drain_all_begin(void)
AioContext *aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
- bdrv_do_drained_begin(bs, false, NULL, true, false);
+ bdrv_do_drained_begin(bs, false, NULL, true, false, false);
aio_context_release(aio_context);
}
diff --git a/include/block/block-io.h b/include/block/block-io.h
index e2789dd344..457e77bfce 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -249,6 +249,7 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
* exclusive access to all child nodes as well.
*/
void bdrv_subtree_drained_begin(BlockDriverState *bs);
+void bdrv_subtree_drained_begin_unlocked(BlockDriverState *bs);
/**
* bdrv_drained_end:
@@ -281,6 +282,7 @@ void bdrv_drained_end_no_poll(BlockDriverState *bs, int *drained_end_counter);
* End a quiescent section started by bdrv_subtree_drained_begin().
*/
void bdrv_subtree_drained_end(BlockDriverState *bs);
+void bdrv_subtree_drained_end_unlocked(BlockDriverState *bs);
bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
uint32_t granularity, Error **errp);
--
2.31.1
next prev parent reply other threads:[~2021-12-13 10:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-13 10:40 [RFC PATCH 0/6] Removal of Aiocontext lock and usage of subtree drains in aborted transactions Emanuele Giuseppe Esposito
2021-12-13 10:40 ` [RFC PATCH 1/6] tests/unit/test-bdrv-drain.c: graph setup functions can't run in coroutines Emanuele Giuseppe Esposito
2021-12-13 10:40 ` [RFC PATCH 2/6] introduce BDRV_POLL_WHILE_UNLOCKED Emanuele Giuseppe Esposito
2021-12-13 10:40 ` Emanuele Giuseppe Esposito [this message]
2021-12-13 10:40 ` [RFC PATCH 4/6] block.c: add subtree_drains where needed Emanuele Giuseppe Esposito
2021-12-13 10:40 ` [RFC PATCH 5/6] test-bdrv-drain.c: adapt test to the new subtree drains Emanuele Giuseppe Esposito
2021-12-13 10:40 ` [RFC PATCH 6/6] block/io.c: enable assert_bdrv_graph_writable Emanuele Giuseppe Esposito
2021-12-13 14:52 ` [RFC PATCH 0/6] Removal of Aiocontext lock and usage of subtree drains in aborted transactions Stefan Hajnoczi
2021-12-14 18:10 ` Emanuele Giuseppe Esposito
2021-12-15 12:34 ` Hanna Reitz
2021-12-16 10:37 ` Kevin Wolf
2021-12-14 16:47 ` Stefan Hajnoczi
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=20211213104014.69858-4-eesposit@redhat.com \
--to=eesposit@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.