mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
block: Mark bdrv_skip_filters() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_skip_filters() need to hold a reader lock for the graph because it calls bdrv_filter_child(), which accesses bs->file/backing. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20231027155333.420094-9-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
430da832af
commit
ad74751fc0
9 changed files with 77 additions and 31 deletions
|
@ -53,8 +53,8 @@ static int coroutine_fn stream_populate(BlockBackend *blk,
|
|||
static int stream_prepare(Job *job)
|
||||
{
|
||||
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
|
||||
BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
|
||||
BlockDriverState *unfiltered_bs_cow = bdrv_cow_bs(unfiltered_bs);
|
||||
BlockDriverState *unfiltered_bs;
|
||||
BlockDriverState *unfiltered_bs_cow;
|
||||
BlockDriverState *base;
|
||||
BlockDriverState *unfiltered_base;
|
||||
Error *local_err = NULL;
|
||||
|
@ -62,6 +62,11 @@ static int stream_prepare(Job *job)
|
|||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
bdrv_graph_rdlock_main_loop();
|
||||
unfiltered_bs = bdrv_skip_filters(s->target_bs);
|
||||
unfiltered_bs_cow = bdrv_cow_bs(unfiltered_bs);
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
|
||||
/* We should drop filter at this point, as filter hold the backing chain */
|
||||
bdrv_cor_filter_drop(s->cor_filter_bs);
|
||||
s->cor_filter_bs = NULL;
|
||||
|
@ -142,18 +147,19 @@ static void stream_clean(Job *job)
|
|||
static int coroutine_fn stream_run(Job *job, Error **errp)
|
||||
{
|
||||
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
|
||||
BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
|
||||
BlockDriverState *unfiltered_bs;
|
||||
int64_t len;
|
||||
int64_t offset = 0;
|
||||
int error = 0;
|
||||
int64_t n = 0; /* bytes */
|
||||
|
||||
if (unfiltered_bs == s->base_overlay) {
|
||||
/* Nothing to stream */
|
||||
return 0;
|
||||
}
|
||||
|
||||
WITH_GRAPH_RDLOCK_GUARD() {
|
||||
unfiltered_bs = bdrv_skip_filters(s->target_bs);
|
||||
if (unfiltered_bs == s->base_overlay) {
|
||||
/* Nothing to stream */
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = bdrv_co_getlength(s->target_bs);
|
||||
if (len < 0) {
|
||||
return len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue