From 0ed4b7e81898ee7003aee3488a0fa693474a0890 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 12 Jun 2017 13:33:33 +0200 Subject: [PATCH 07/13] commit: Fix completion with extra reference RH-Author: Kevin Wolf Message-id: <1497274415-4884-2-git-send-email-kwolf@redhat.com> Patchwork-id: 75588 O-Subject: [RHEL-7.4 qemu-kvm-rhev PATCH 1/3] commit: Fix completion with extra reference Bugzilla: 1453169 RH-Acked-by: Max Reitz RH-Acked-by: Jeffrey Cody RH-Acked-by: John Snow commit_complete() can't assume that after its block_job_completed() the job is actually immediately freed; someone else may still be holding references. In this case, the op blockers on the intermediate nodes make the graph reconfiguration in the completion code fail. Call block_job_remove_all_bdrv() manually so that we know for sure that any blockers on intermediate nodes are given up. Upstream status: Applied to git://repo.or.cz/qemu/kevin.git block Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz Signed-off-by: Miroslav Rezanina --- block/commit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/commit.c b/block/commit.c index 3bae46e..fba25e2 100644 --- a/block/commit.c +++ b/block/commit.c @@ -119,6 +119,13 @@ static void commit_complete(BlockJob *job, void *opaque) } g_free(s->backing_file_str); blk_unref(s->top); + + /* If there is more than one reference to the job (e.g. if called from + * block_job_finish_sync()), block_job_completed() won't free it and + * therefore the blockers on the intermediate nodes remain. This would + * cause bdrv_set_backing_hd() to fail. */ + block_job_remove_all_bdrv(job); + block_job_completed(&s->common, ret); g_free(data); -- 1.8.3.1