aboutsummaryrefslogtreecommitdiff
path: root/block/block-copy.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2024-06-27 20:12:44 +0200
committerKevin Wolf <kwolf@redhat.com>2024-08-06 20:12:39 +0200
commitd5f6cbb263662af585b866481382c3f5ba5cd638 (patch)
tree948bd5a3b739d67377bd32e45d8d2ad69d481046 /block/block-copy.c
parentf0e0c46309dac41a8420bcb379b1cffa7da0f62c (diff)
downloadqemu-d5f6cbb263662af585b866481382c3f5ba5cd638.zip
qemu-d5f6cbb263662af585b866481382c3f5ba5cd638.tar.gz
qemu-d5f6cbb263662af585b866481382c3f5ba5cd638.tar.bz2
block-copy: Fix missing graph lock
The graph lock needs to be held when calling bdrv_co_pdiscard(). Fix block_copy_task_entry() to take it for the call. WITH_GRAPH_RDLOCK_GUARD() was implemented in a weak way because of limitations in clang's Thread Safety Analysis at the time, so that it only asserts that the lock is held (which allows calling functions that require the lock), but we never deal with the unlocking (so even after the scope of the guard, the compiler assumes that the lock is still held). This is why the compiler didn't catch this locking error. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20240627181245.281403-2-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/block-copy.c')
-rw-r--r--block/block-copy.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/block/block-copy.c b/block/block-copy.c
index 7e3b378..cc618e4 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -595,7 +595,9 @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
if (s->discard_source && ret == 0) {
int64_t nbytes =
MIN(t->req.offset + t->req.bytes, s->len) - t->req.offset;
- bdrv_co_pdiscard(s->source, t->req.offset, nbytes);
+ WITH_GRAPH_RDLOCK_GUARD() {
+ bdrv_co_pdiscard(s->source, t->req.offset, nbytes);
+ }
}
return ret;