Received: from eggs.gnu.org ([2001:4830:134:3::10]:34298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1GLp-00078N-Ep for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:26:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1GLo-0008UZ-Iw for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:26:25 -0400 From: Kevin Wolf Date: Mon, 31 Oct 2016 18:25:41 +0100 Message-Id: <1477934758-29332-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1477934758-29332-1-git-send-email-kwolf@redhat.com> References: <1477934758-29332-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 12/29] block: Block all nodes involved in the block-commit operation 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 From: Alberto Garcia After a successful block-commit operation all nodes between top and base are removed from the backing chain, and top's overlay needs to be updated to point to base. Because of that we should prevent other block jobs from messing with them. This patch blocks all operations in these nodes in commit_start(). Signed-off-by: Alberto Garcia Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/commit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/commit.c b/block/commit.c index 499ecca..a5e17f6 100644 --- a/block/commit.c +++ b/block/commit.c @@ -216,6 +216,7 @@ void commit_start(const char *job_id, BlockDriverState *bs, BlockReopenQueue *reopen_queue = NULL; int orig_overlay_flags; int orig_base_flags; + BlockDriverState *iter; BlockDriverState *overlay_bs; Error *local_err = NULL; @@ -260,6 +261,19 @@ void commit_start(const char *job_id, BlockDriverState *bs, } + /* Block all nodes between top and base, because they will + * disappear from the chain after this operation. */ + assert(bdrv_chain_contains(top, base)); + for (iter = top; iter != backing_bs(base); iter = backing_bs(iter)) { + block_job_add_bdrv(&s->common, iter); + } + /* overlay_bs must be blocked because it needs to be modified to + * update the backing image string, but if it's the root node then + * don't block it again */ + if (bs != overlay_bs) { + block_job_add_bdrv(&s->common, overlay_bs); + } + s->base = blk_new(); blk_insert_bs(s->base, base); -- 1.8.3.1