aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-09-11 11:46:18 +0200
committerKevin Wolf <kwolf@redhat.com>2023-09-20 17:46:01 +0200
commitede01e4635050a395eacd57b7d7fbea8ea208704 (patch)
tree92113b8f904153f9ab38134a921b8993240c0946 /block.c
parent7f831d29e3d005e499b22c0591a26a33eb5c406d (diff)
downloadqemu-ede01e4635050a395eacd57b7d7fbea8ea208704.zip
qemu-ede01e4635050a395eacd57b7d7fbea8ea208704.tar.gz
qemu-ede01e4635050a395eacd57b7d7fbea8ea208704.tar.bz2
block: Mark bdrv_root_unref_child() GRAPH_WRLOCK
Instead of taking the writer lock internally, require callers to already hold it when calling bdrv_root_unref_child(). These callers will typically already hold the graph lock once the locking work is completed, which means that they can't call functions that take it internally. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20230911094620.45040-20-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/block.c b/block.c
index 8e589bb..9ea8333 100644
--- a/block.c
+++ b/block.c
@@ -3268,7 +3268,6 @@ void bdrv_root_unref_child(BdrvChild *child)
BlockDriverState *child_bs = child->bs;
GLOBAL_STATE_CODE();
- bdrv_graph_wrlock(NULL);
bdrv_replace_child_noperm(child, NULL);
bdrv_child_free(child);
@@ -3288,8 +3287,7 @@ void bdrv_root_unref_child(BdrvChild *child)
NULL);
}
- bdrv_graph_wrunlock();
- bdrv_unref(child_bs);
+ bdrv_schedule_unref(child_bs);
}
typedef struct BdrvSetInheritsFrom {
@@ -3366,8 +3364,10 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
return;
}
+ bdrv_graph_wrlock(NULL);
bdrv_unset_inherits_from(parent, child, NULL);
bdrv_root_unref_child(child);
+ bdrv_graph_wrunlock();
}