From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJIQe-0006n4-D8 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 07:50:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJIQd-0001vM-KH for qemu-devel@nongnu.org; Fri, 09 Jun 2017 07:50:12 -0400 From: Kevin Wolf Date: Fri, 9 Jun 2017 13:50:01 +0200 Message-Id: <1497009003-25794-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1497009003-25794-1-git-send-email-kwolf@redhat.com> References: <1497009003-25794-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] commit: Fix completion with extra reference List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org 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. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf --- block/commit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/commit.c b/block/commit.c index af6fa68..8c09c3d 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