[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 3/6] block/io.c: introduce bdrv_subtree_drained_{begin/end}_u
From: |
Emanuele Giuseppe Esposito |
Subject: |
[RFC PATCH 3/6] block/io.c: introduce bdrv_subtree_drained_{begin/end}_unlocked |
Date: |
Mon, 13 Dec 2021 05:40:11 -0500 |
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
- [RFC PATCH 0/6] Removal of Aiocontext lock and usage of subtree drains in aborted transactions, Emanuele Giuseppe Esposito, 2021/12/13
- [RFC PATCH 2/6] introduce BDRV_POLL_WHILE_UNLOCKED, Emanuele Giuseppe Esposito, 2021/12/13
- [RFC PATCH 3/6] block/io.c: introduce bdrv_subtree_drained_{begin/end}_unlocked,
Emanuele Giuseppe Esposito <=
- [RFC PATCH 1/6] tests/unit/test-bdrv-drain.c: graph setup functions can't run in coroutines, Emanuele Giuseppe Esposito, 2021/12/13
- [RFC PATCH 5/6] test-bdrv-drain.c: adapt test to the new subtree drains, Emanuele Giuseppe Esposito, 2021/12/13
- [RFC PATCH 4/6] block.c: add subtree_drains where needed, Emanuele Giuseppe Esposito, 2021/12/13
- [RFC PATCH 6/6] block/io.c: enable assert_bdrv_graph_writable, Emanuele Giuseppe Esposito, 2021/12/13
- Re: [RFC PATCH 0/6] Removal of Aiocontext lock and usage of subtree drains in aborted transactions, Stefan Hajnoczi, 2021/12/13
- Re: [RFC PATCH 0/6] Removal of Aiocontext lock and usage of subtree drains in aborted transactions, Stefan Hajnoczi, 2021/12/14