[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/39] block: bdrv_reopen_multiple(): move bdrv_flush to separate
From: |
Kevin Wolf |
Subject: |
[PULL 29/39] block: bdrv_reopen_multiple(): move bdrv_flush to separate pre-prepare |
Date: |
Fri, 30 Apr 2021 12:51:37 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
During reopen we may add backing bs from other aio context, which may
lead to changing original context of top bs.
We are going to move graph modification to prepare stage. So, it will
be possible that bdrv_flush() in bdrv_reopen_prepare called on bs in
non-original aio context, which we didn't aquire which leads to crash.
To avoid this problem move bdrv_flush() to be a separate reopen stage
before bdrv_reopen_prepare().
This doesn't seem correct to acquire only one aio context and not all
contexts participating in reopen. But it's not obvious how to do it
correctly, keeping in mind:
1. rules of bdrv_set_aio_context_ignore() that requires new_context
lock not being held
2. possible deadlocks because of holding all (or several?) AioContext
locks
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210428151804.439460-30-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index bdfe59d94d..357ec1be2c 100644
--- a/block.c
+++ b/block.c
@@ -4274,6 +4274,14 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue,
Error **errp)
assert(bs_queue != NULL);
+ QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
+ ret = bdrv_flush(bs_entry->state.bs);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "Error flushing drive");
+ goto cleanup;
+ }
+ }
+
QTAILQ_FOREACH(bs_entry, bs_queue, entry) {
assert(bs_entry->state.bs->quiesce_counter > 0);
if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, errp)) {
@@ -4669,12 +4677,6 @@ static int bdrv_reopen_prepare(BDRVReopenState
*reopen_state,
bdrv_reopen_perm(queue, reopen_state->bs,
&reopen_state->perm, &reopen_state->shared_perm);
- ret = bdrv_flush(reopen_state->bs);
- if (ret) {
- error_setg_errno(errp, -ret, "Error flushing drive");
- goto error;
- }
-
if (drv->bdrv_reopen_prepare) {
/*
* If a driver-specific option is missing, it means that we
--
2.30.2
- [PULL 21/39] block: adapt bdrv_append() for inserting filters, (continued)
- [PULL 21/39] block: adapt bdrv_append() for inserting filters, Kevin Wolf, 2021/04/30
- [PULL 20/39] block: split out bdrv_replace_node_noperm(), Kevin Wolf, 2021/04/30
- [PULL 23/39] block: introduce bdrv_drop_filter(), Kevin Wolf, 2021/04/30
- [PULL 19/39] block: add bdrv_attach_child_noperm() transaction action, Kevin Wolf, 2021/04/30
- [PULL 22/39] block: add bdrv_remove_filter_or_cow transaction action, Kevin Wolf, 2021/04/30
- [PULL 26/39] block: make bdrv_unset_inherits_from to be a transaction action, Kevin Wolf, 2021/04/30
- [PULL 16/39] block: add bdrv_replace_child_safe() transaction action, Kevin Wolf, 2021/04/30
- [PULL 27/39] block: make bdrv_refresh_limits() to be a transaction action, Kevin Wolf, 2021/04/30
- [PULL 24/39] block/backup-top: drop .active, Kevin Wolf, 2021/04/30
- [PULL 25/39] block: drop ignore_children for permission update functions, Kevin Wolf, 2021/04/30
- [PULL 29/39] block: bdrv_reopen_multiple(): move bdrv_flush to separate pre-prepare,
Kevin Wolf <=
- [PULL 33/39] block: inline bdrv_replace_child(), Kevin Wolf, 2021/04/30
- [PULL 28/39] block: add bdrv_set_backing_noperm() transaction action, Kevin Wolf, 2021/04/30
- [PULL 34/39] block: refactor bdrv_child_set_perm_safe() transaction action, Kevin Wolf, 2021/04/30
- [PULL 30/39] block: bdrv_reopen_multiple: refresh permissions on updated graph, Kevin Wolf, 2021/04/30
- [PULL 36/39] block: refactor bdrv_node_check_perm(), Kevin Wolf, 2021/04/30
- [PULL 31/39] block: drop unused permission update functions, Kevin Wolf, 2021/04/30
- [PULL 32/39] block: inline bdrv_check_perm_common(), Kevin Wolf, 2021/04/30
- [PULL 39/39] vhost-user-blk: Fail gracefully on too large queue size, Kevin Wolf, 2021/04/30
- [PULL 37/39] block: Add BDRV_O_NO_SHARE for blk_new_open(), Kevin Wolf, 2021/04/30