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