[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 43/51] block: Fix locking in external_snapshot_prepare()
From: |
Kevin Wolf |
Subject: |
[PULL 43/51] block: Fix locking in external_snapshot_prepare() |
Date: |
Wed, 14 Dec 2022 14:44:45 +0100 |
bdrv_img_create() polls internally (when calling bdrv_create(), which is
a co_wrapper), so it can't be called while holding the lock of any
AioContext except the current one without causing deadlocks. Drop the
lock around the call in external_snapshot_prepare().
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20221207131838.239125-11-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 4 ++++
blockdev.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/block.c b/block.c
index 6191ac1f44..44d59362d6 100644
--- a/block.c
+++ b/block.c
@@ -6924,6 +6924,10 @@ bool bdrv_op_blocker_is_empty(BlockDriverState *bs)
return true;
}
+/*
+ * Must not be called while holding the lock of an AioContext other than the
+ * current one.
+ */
void bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
char *options, uint64_t img_size, int flags, bool quiet,
diff --git a/blockdev.c b/blockdev.c
index 8ffb3d9537..011e48df7b 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1524,10 +1524,14 @@ static void external_snapshot_prepare(BlkActionState
*common,
goto out;
}
bdrv_refresh_filename(state->old_bs);
+
+ aio_context_release(aio_context);
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, size, flags, false, &local_err);
+ aio_context_acquire(aio_context);
+
if (local_err) {
error_propagate(errp, local_err);
goto out;
--
2.38.1
- [PULL 37/51] async: Register/unregister aiocontext in graph lock list, (continued)
- [PULL 37/51] async: Register/unregister aiocontext in graph lock list, Kevin Wolf, 2022/12/14
- [PULL 50/51] block: use co_wrapper_mixed_bdrv_rdlock in functions taking the rdlock, Kevin Wolf, 2022/12/14
- [PULL 47/51] graph-lock: TSA annotations for lock/unlock functions, Kevin Wolf, 2022/12/14
- [PULL 48/51] Mark assert_bdrv_graph_readable/writable() GRAPH_RD/WRLOCK, Kevin Wolf, 2022/12/14
- [PULL 46/51] block: assert that graph read and writes are performed correctly, Kevin Wolf, 2022/12/14
- [PULL 30/51] block-coroutine-wrapper.py: support functions without bs arg, Kevin Wolf, 2022/12/14
- [PULL 34/51] block: Factor out bdrv_drain_all_begin_nopoll(), Kevin Wolf, 2022/12/14
- [PULL 44/51] block: wrlock in bdrv_replace_child_noperm, Kevin Wolf, 2022/12/14
- [PULL 45/51] block: remove unnecessary assert_bdrv_graph_writable(), Kevin Wolf, 2022/12/14
- [PULL 39/51] clang-tsa: Add TSA_ASSERT() macro, Kevin Wolf, 2022/12/14
- [PULL 43/51] block: Fix locking in external_snapshot_prepare(),
Kevin Wolf <=
- [PULL 49/51] block-coroutine-wrapper.py: introduce annotations that take the graph rdlock, Kevin Wolf, 2022/12/14
- [PULL 51/51] block: GRAPH_RDLOCK for functions only called by co_wrappers, Kevin Wolf, 2022/12/14
- Re: [PULL 00/51] Block layer patches, Peter Maydell, 2022/12/14