From patchwork Wed Oct 26 10:29:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9396531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 15100600BA for ; Wed, 26 Oct 2016 10:31:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C16E5293AB for ; Wed, 26 Oct 2016 10:31:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B47AE29552; Wed, 26 Oct 2016 10:31:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 69B7B293AB for ; Wed, 26 Oct 2016 10:31:12 +0000 (UTC) Received: from localhost ([::1]:33003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzLUD-0003jl-J0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Oct 2016 06:31:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzLTW-0003gN-4F for qemu-devel@nongnu.org; Wed, 26 Oct 2016 06:30:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzLTR-0001nY-5F for qemu-devel@nongnu.org; Wed, 26 Oct 2016 06:30:26 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:61899 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzLTQ-0001nG-VN; Wed, 26 Oct 2016 06:30:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CSAwB1hRBY/5tjdVtcHQEFAQsBgyoBAQEBAR2BSguNNZVXAQEBAQEBBQGBF5I0gg+CCYYiAoIAPxQBAgEBAQEBAQFiKEIOAYQSAgQnUhA/EjwbGYhYAcBAAQEIJ4VyglCHY4UTBY8+hGWFc5AggW6IBIEohGqHG4lwHjZQBgiDGRyBVW+EFIRSAQEB X-IPAS-Result: A2CSAwB1hRBY/5tjdVtcHQEFAQsBgyoBAQEBAR2BSguNNZVXAQEBAQEBBQGBF5I0gg+CCYYiAoIAPxQBAgEBAQEBAQFiKEIOAYQSAgQnUhA/EjwbGYhYAcBAAQEIJ4VyglCHY4UTBY8+hGWFc5AggW6IBIEohGqHG4lwHjZQBgiDGRyBVW+EFIRSAQEB X-IronPort-AV: E=Sophos;i="5.31,550,1473112800"; d="scan'208";a="202588312" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 26 Oct 2016 12:30:05 +0200 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1bzLT9-00026V-Q2; Wed, 26 Oct 2016 12:30:04 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bzLSr-0001Zg-Pu; Wed, 26 Oct 2016 13:29:45 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 26 Oct 2016 13:29:21 +0300 Message-Id: <645beaadb2d8e0638a920fd0a3d0a1f222b62608.1477476553.git.berto@igalia.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH v12 07/19] block: Block all nodes involved in the block-commit operation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- block/commit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/commit.c b/block/commit.c index 9f67a8b..1500d7c 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);