@@ -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);
}
@@ -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);
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(-)