From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org
Subject: [PULL 27/28] block: Mark bdrv_refresh_limits() and callers GRAPH_RDLOCK
Date: Wed, 10 May 2023 14:21:10 +0200 [thread overview]
Message-ID: <20230510122111.46566-28-kwolf@redhat.com> (raw)
In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com>
This adds GRAPH_RDLOCK annotations to declare that callers of
bdrv_refresh_limits() need to hold a reader lock for the graph because
it accesses the children list of a node.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20230504115750.54437-21-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block-global-state.h | 5 ++++-
include/block/block_int-common.h | 3 ++-
block.c | 9 +++++++++
block/io.c | 1 -
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h
index f234bca0b6..2d93423d35 100644
--- a/include/block/block-global-state.h
+++ b/include/block/block-global-state.h
@@ -133,7 +133,10 @@ int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only,
BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
const char *backing_file);
void bdrv_refresh_filename(BlockDriverState *bs);
-void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp);
+
+void GRAPH_RDLOCK
+bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp);
+
int bdrv_commit(BlockDriverState *bs);
int bdrv_make_empty(BdrvChild *c, Error **errp);
int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file,
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 024ded4fc2..4909876756 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -334,7 +334,8 @@ struct BlockDriver {
int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag);
bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag);
- void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp);
+ void GRAPH_RDLOCK_PTR (*bdrv_refresh_limits)(
+ BlockDriverState *bs, Error **errp);
/*
* Returns 1 if newly created images are guaranteed to contain only
diff --git a/block.c b/block.c
index 1bc766c778..dad9a4fa43 100644
--- a/block.c
+++ b/block.c
@@ -1667,7 +1667,10 @@ bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name,
return ret;
}
+ bdrv_graph_rdlock_main_loop();
bdrv_refresh_limits(bs, NULL, &local_err);
+ bdrv_graph_rdunlock_main_loop();
+
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
@@ -3419,7 +3422,9 @@ static int bdrv_set_file_or_backing_noperm(BlockDriverState *parent_bs,
}
out:
+ bdrv_graph_rdlock_main_loop();
bdrv_refresh_limits(parent_bs, tran, NULL);
+ bdrv_graph_rdunlock_main_loop();
return 0;
}
@@ -4917,7 +4922,9 @@ static void bdrv_reopen_commit(BDRVReopenState *reopen_state)
qdict_del(bs->explicit_options, "backing");
qdict_del(bs->options, "backing");
+ bdrv_graph_rdlock_main_loop();
bdrv_refresh_limits(bs, NULL, NULL);
+ bdrv_graph_rdunlock_main_loop();
bdrv_refresh_total_sectors(bs, bs->total_sectors);
}
@@ -5316,7 +5323,9 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
out:
tran_finalize(tran, ret);
+ bdrv_graph_rdlock_main_loop();
bdrv_refresh_limits(bs_top, NULL, NULL);
+ bdrv_graph_rdunlock_main_loop();
if (new_context && old_context != new_context) {
aio_context_release(new_context);
diff --git a/block/io.c b/block/io.c
index 3bf9ef9d87..58557f2f96 100644
--- a/block/io.c
+++ b/block/io.c
@@ -160,7 +160,6 @@ void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp)
bool have_limits;
GLOBAL_STATE_CODE();
- assume_graph_lock(); /* FIXME */
if (tran) {
BdrvRefreshLimitsState *s = g_new(BdrvRefreshLimitsState, 1);
--
2.40.1
next prev parent reply other threads:[~2023-05-10 12:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 12:20 [PULL 00/28] Block layer patches Kevin Wolf
2023-05-10 12:20 ` [PULL 01/28] block: add configure options for excluding vmdk, vhdx and vpc Kevin Wolf
2023-05-10 12:20 ` [PULL 02/28] block: add missing coroutine_fn annotations Kevin Wolf
2023-05-10 12:20 ` [PULL 03/28] aio-wait: avoid AioContext lock in aio_wait_bh_oneshot() Kevin Wolf
2023-05-10 12:20 ` [PULL 04/28] block: Fix use after free in blockdev_mark_auto_del() Kevin Wolf
2023-05-10 12:20 ` [PULL 05/28] iotests/nbd-reconnect-on-open: Fix NBD socket path Kevin Wolf
2023-05-10 12:20 ` [PULL 06/28] migration: Attempt disk reactivation in more failure scenarios Kevin Wolf
2023-05-10 12:20 ` [PULL 07/28] qcow2: Don't call bdrv_getlength() in coroutine_fns Kevin Wolf
2023-05-10 12:20 ` [PULL 08/28] block: Consistently call bdrv_activate() outside coroutine Kevin Wolf
2023-05-10 12:20 ` [PULL 09/28] block: bdrv/blk_co_unref() for calls in coroutine context Kevin Wolf
2023-05-11 15:32 ` Michael Tokarev
2023-05-15 13:07 ` Kevin Wolf
2023-05-15 14:25 ` Michael Tokarev
2023-05-10 12:20 ` [PULL 10/28] block: Don't call no_coroutine_fns in qmp_block_resize() Kevin Wolf
2023-05-10 12:20 ` [PULL 11/28] iotests: Test resizing image attached to an iothread Kevin Wolf
2023-05-10 12:20 ` [PULL 12/28] test-bdrv-drain: Don't modify the graph in coroutines Kevin Wolf
2023-05-10 12:20 ` [PULL 13/28] graph-lock: Add GRAPH_UNLOCKED(_PTR) Kevin Wolf
2023-05-10 12:20 ` [PULL 14/28] graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock Kevin Wolf
2023-05-10 12:20 ` [PULL 15/28] block: .bdrv_open is non-coroutine and unlocked Kevin Wolf
2023-05-10 12:20 ` [PULL 16/28] nbd: Remove nbd_co_flush() wrapper function Kevin Wolf
2023-05-10 12:21 ` [PULL 17/28] nbd: Mark nbd_co_do_establish_connection() and callers GRAPH_RDLOCK Kevin Wolf
2023-05-10 12:21 ` [PULL 18/28] vhdx: Require GRAPH_RDLOCK for accessing a node's parent list Kevin Wolf
2023-05-10 12:21 ` [PULL 19/28] mirror: " Kevin Wolf
2023-05-10 12:21 ` [PULL 20/28] block: Mark bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK Kevin Wolf
2023-05-10 12:21 ` [PULL 21/28] block: Mark bdrv_co_get_info() " Kevin Wolf
2023-05-10 12:21 ` [PULL 22/28] block: Mark bdrv_co_debug_event() GRAPH_RDLOCK Kevin Wolf
2023-05-10 12:21 ` [PULL 23/28] block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK Kevin Wolf
2023-05-10 12:21 ` [PULL 24/28] block: Mark bdrv_query_bds_stats() and callers GRAPH_RDLOCK Kevin Wolf
2023-05-10 12:21 ` [PULL 25/28] block: Mark bdrv_query_block_graph_info() " Kevin Wolf
2023-05-10 12:21 ` [PULL 26/28] block: Mark bdrv_recurse_can_replace() " Kevin Wolf
2023-05-10 12:21 ` Kevin Wolf [this message]
2023-05-10 12:21 ` [PULL 28/28] block: compile out assert_bdrv_graph_readable() by default Kevin Wolf
2023-05-10 15:42 ` [PULL 00/28] Block layer patches Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230510122111.46566-28-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).