block: Mark bdrv_attach_child_common() GRAPH_WRLOCK
commit7d4ca9d25bce7e7cd3f1188ec5e5c46c649310c7
authorKevin Wolf <kwolf@redhat.com>
Mon, 11 Sep 2023 09:46:09 +0000 (11 11:46 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 20 Sep 2023 15:46:01 +0000 (20 17:46 +0200)
treea19f7499b05ddafe813f3466a864a73d22417d61
parent2f64e1fc57f1a275637ff6c34cb1a7207dc9e8c8
block: Mark bdrv_attach_child_common() GRAPH_WRLOCK

Instead of taking the writer lock internally, require callers to already
hold it when calling bdrv_attach_child_common(). 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.

Note that the transaction callbacks still take the lock internally, so
tran_finalize() must be called without the lock held. This is because
bdrv_append() also calls bdrv_replace_node_noperm(), which currently
requires the transaction callbacks to be called unlocked. In the next
step, both of them can be switched to locked tran_finalize() calls
together.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230911094620.45040-11-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block/stream.c