[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/13] block: Fix cross-AioContext blockdev-snapshot
From: |
Kevin Wolf |
Subject: |
[PULL 06/13] block: Fix cross-AioContext blockdev-snapshot |
Date: |
Wed, 11 Mar 2020 16:42:11 +0100 |
external_snapshot_prepare() tries to move the overlay to the AioContext
of the backing file (the snapshotted node). However, it's possible that
this doesn't work, but the backing file can instead be moved to the
overlay's AioContext (e.g. opening the backing chain for a mirror
target).
bdrv_append() already indirectly uses bdrv_attach_node(), which takes
care to move nodes to make sure they use the same AioContext and which
tries both directions.
So the problem has a simple fix: Just delete the unnecessary extra
bdrv_try_set_aio_context() call in external_snapshot_prepare() and
instead assert in bdrv_append() that both nodes were indeed moved to the
same AioContext.
Signed-off-by: Kevin Wolf <address@hidden>
Message-Id: <address@hidden>
Tested-by: Peter Krempa <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 1 +
blockdev.c | 16 ----------------
2 files changed, 1 insertion(+), 16 deletions(-)
diff --git a/block.c b/block.c
index 79a5a2770f..8fc7b56937 100644
--- a/block.c
+++ b/block.c
@@ -4365,6 +4365,7 @@ void bdrv_replace_node(BlockDriverState *from,
BlockDriverState *to,
bdrv_ref(from);
assert(qemu_get_current_aio_context() == qemu_get_aio_context());
+ assert(bdrv_get_aio_context(from) == bdrv_get_aio_context(to));
bdrv_drained_begin(from);
/* Put all parents into @list and calculate their cumulative permissions */
diff --git a/blockdev.c b/blockdev.c
index ea89896f27..fa8630cb41 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1470,9 +1470,7 @@ static void external_snapshot_prepare(BlkActionState
*common,
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
AioContext *aio_context;
- AioContext *old_context;
uint64_t perm, shared;
- int ret;
/* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar
* purpose but a different set of parameters */
@@ -1608,20 +1606,6 @@ static void external_snapshot_prepare(BlkActionState
*common,
goto out;
}
- /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
- old_context = bdrv_get_aio_context(state->new_bs);
- aio_context_release(aio_context);
- aio_context_acquire(old_context);
-
- ret = bdrv_try_set_aio_context(state->new_bs, aio_context, errp);
-
- aio_context_release(old_context);
- aio_context_acquire(aio_context);
-
- if (ret < 0) {
- goto out;
- }
-
/* This removes our old bs and adds the new bs. This is an operation that
* can fail, so we need to do it in .prepare; undoing it for abort is
* always possible. */
--
2.20.1
- [PULL 00/13] Block layer patches, Kevin Wolf, 2020/03/11
- [PULL 01/13] qom-qmp-cmds: fix two memleaks in qmp_object_add, Kevin Wolf, 2020/03/11
- [PULL 04/13] iotests: Fix run_job() with use_log=False, Kevin Wolf, 2020/03/11
- [PULL 03/13] block: Relax restrictions for blockdev-snapshot, Kevin Wolf, 2020/03/11
- [PULL 05/13] iotests: Test mirror with temporarily disabled target backing file, Kevin Wolf, 2020/03/11
- [PULL 06/13] block: Fix cross-AioContext blockdev-snapshot,
Kevin Wolf <=
- [PULL 02/13] block: Make bdrv_get_cumulative_perm() public, Kevin Wolf, 2020/03/11
- [PULL 08/13] qapi: Add '@allow-write-only-overlay' feature for 'blockdev-snapshot', Kevin Wolf, 2020/03/11
- [PULL 07/13] iotests: Add iothread cases to 155, Kevin Wolf, 2020/03/11
- [PULL 09/13] tests/qemu-iotests: Fix socket_scm_helper build path, Kevin Wolf, 2020/03/11
- [PULL 12/13] crypto.c: cleanup created file when block_crypto_co_create_opts_luks fails, Kevin Wolf, 2020/03/11
- [PULL 10/13] block: introducing 'bdrv_co_delete_file' interface, Kevin Wolf, 2020/03/11
- [PULL 13/13] qemu-iotests: adding LUKS cleanup for non-UTF8 secret error, Kevin Wolf, 2020/03/11
- [PULL 11/13] block.c: adding bdrv_co_delete_file, Kevin Wolf, 2020/03/11
- Re: [PULL 00/13] Block layer patches, Peter Maydell, 2020/03/12