[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/22] block: Mark bdrv_amend_options() and callers GRAPH_RDLOCK
From: |
Kevin Wolf |
Subject: |
[PATCH 13/22] block: Mark bdrv_amend_options() and callers GRAPH_RDLOCK |
Date: |
Fri, 29 Sep 2023 16:51:48 +0200 |
This adds GRAPH_RDLOCK annotations to declare that callers of
bdrv_amend_options() need to hold a reader lock for the graph. This
removes an assume_graph_lock() call in crypto's implementation.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block-global-state.h | 8 ++++----
include/block/block_int-common.h | 10 ++++------
block/crypto.c | 4 +---
qemu-img.c | 7 +++++++
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/include/block/block-global-state.h
b/include/block/block-global-state.h
index ec623ef3c9..9dc35133a8 100644
--- a/include/block/block-global-state.h
+++ b/include/block/block-global-state.h
@@ -160,10 +160,10 @@ void bdrv_unfreeze_backing_chain(BlockDriverState *bs,
BlockDriverState *base);
*/
typedef void BlockDriverAmendStatusCB(BlockDriverState *bs, int64_t offset,
int64_t total_work_size, void *opaque);
-int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts,
- BlockDriverAmendStatusCB *status_cb, void *cb_opaque,
- bool force,
- Error **errp);
+int GRAPH_RDLOCK
+bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts,
+ BlockDriverAmendStatusCB *status_cb, void *cb_opaque,
+ bool force, Error **errp);
/* check if a named node can be replaced when doing drive-mirror */
BlockDriverState * GRAPH_RDLOCK
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index be80887898..c8661775f4 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -259,12 +259,10 @@ struct BlockDriver {
int coroutine_fn GRAPH_UNLOCKED_PTR (*bdrv_co_create_opts)(
BlockDriver *drv, const char *filename, QemuOpts *opts, Error **errp);
- int (*bdrv_amend_options)(BlockDriverState *bs,
- QemuOpts *opts,
- BlockDriverAmendStatusCB *status_cb,
- void *cb_opaque,
- bool force,
- Error **errp);
+ int GRAPH_RDLOCK_PTR (*bdrv_amend_options)(
+ BlockDriverState *bs, QemuOpts *opts,
+ BlockDriverAmendStatusCB *status_cb, void *cb_opaque,
+ bool force, Error **errp);
int (*bdrv_make_empty)(BlockDriverState *bs);
diff --git a/block/crypto.c b/block/crypto.c
index c9c9a39fa3..b3f0233d53 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -828,7 +828,7 @@ block_crypto_amend_options_generic_luks(BlockDriverState
*bs,
errp);
}
-static int
+static int GRAPH_RDLOCK
block_crypto_amend_options_luks(BlockDriverState *bs,
QemuOpts *opts,
BlockDriverAmendStatusCB *status_cb,
@@ -841,8 +841,6 @@ block_crypto_amend_options_luks(BlockDriverState *bs,
QCryptoBlockAmendOptions *amend_options = NULL;
int ret = -EINVAL;
- assume_graph_lock(); /* FIXME */
-
assert(crypto);
assert(crypto->block);
diff --git a/qemu-img.c b/qemu-img.c
index f7fa49fe65..6d8cab69a5 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4129,6 +4129,8 @@ static int print_amend_option_help(const char *format)
{
BlockDriver *drv;
+ GRAPH_RDLOCK_GUARD_MAINLOOP();
+
/* Find driver and parse its options */
drv = bdrv_find_format(format);
if (!drv) {
@@ -4267,9 +4269,11 @@ static int img_amend(int argc, char **argv)
goto out;
}
+ bdrv_graph_rdlock_main_loop();
if (!bs->drv->bdrv_amend_options) {
error_report("Format driver '%s' does not support option amendment",
fmt);
+ bdrv_graph_rdunlock_main_loop();
ret = -1;
goto out;
}
@@ -4289,6 +4293,7 @@ static int img_amend(int argc, char **argv)
"This option is only supported for image
creation\n");
}
+ bdrv_graph_rdunlock_main_loop();
error_report_err(err);
ret = -1;
goto out;
@@ -4298,6 +4303,8 @@ static int img_amend(int argc, char **argv)
qemu_progress_print(0.f, 0);
ret = bdrv_amend_options(bs, opts, &amend_status_cb, NULL, force, &err);
qemu_progress_print(100.f, 0);
+ bdrv_graph_rdunlock_main_loop();
+
if (ret < 0) {
error_report_err(err);
goto out;
--
2.41.0
- [PATCH 02/22] block-coroutine-wrapper: Add no_co_wrapper_bdrv_rdlock functions, (continued)
- [PATCH 02/22] block-coroutine-wrapper: Add no_co_wrapper_bdrv_rdlock functions, Kevin Wolf, 2023/09/29
- [PATCH 01/22] test-bdrv-drain: Don't call bdrv_graph_wrlock() in coroutine context, Kevin Wolf, 2023/09/29
- [PATCH 05/22] block: Mark drain related functions GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 04/22] block: Mark bdrv_first_blk() and bdrv_is_root_node() GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 07/22] block: Mark bdrv_snapshot_fallback() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 06/22] block: Mark bdrv_parent_cb_resize() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 08/22] block: Take graph rdlock in parts of reopen, Kevin Wolf, 2023/09/29
- [PATCH 09/22] block: Mark bdrv_get_xdbg_block_graph() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 10/22] block: Mark bdrv_refresh_filename() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 12/22] block: Mark bdrv_get_parent_name() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 13/22] block: Mark bdrv_amend_options() and callers GRAPH_RDLOCK,
Kevin Wolf <=
- [PATCH 15/22] qcow2: Mark qcow2_inactivate() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 14/22] qcow2: Mark qcow2_signal_corruption() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 17/22] block: Mark bdrv_op_is_blocked() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 16/22] qcow2: Mark check_constraints_on_bitmap() GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 11/22] block: Mark bdrv_primary_child() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 18/22] block: Mark bdrv_apply_auto_read_only() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 21/22] block: Protect bs->children with graph_lock, Kevin Wolf, 2023/09/29
- [PATCH 19/22] block: Mark bdrv_get_specific_info() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/09/29
- [PATCH 20/22] block: Protect bs->parents with graph_lock, Kevin Wolf, 2023/09/29
- [PATCH 22/22] block: Add assertion for bdrv_graph_wrlock(), Kevin Wolf, 2023/09/29