From patchwork Mon Aug 22 03:36:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9292849 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 1E19C60574 for ; Mon, 22 Aug 2016 03:37:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D567287E7 for ; Mon, 22 Aug 2016 03:37:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01AC52883B; Mon, 22 Aug 2016 03:37:26 +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 1AA20287E7 for ; Mon, 22 Aug 2016 03:37:25 +0000 (UTC) Received: from localhost ([::1]:39316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbg39-0000yA-Ak for patchwork-qemu-devel@patchwork.kernel.org; Sun, 21 Aug 2016 23:37:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbg2r-0000y2-6z for qemu-devel@nongnu.org; Sun, 21 Aug 2016 23:37:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bbg2l-0002tz-7B for qemu-devel@nongnu.org; Sun, 21 Aug 2016 23:37:04 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:9309 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbg2k-0002mk-Vf; Sun, 21 Aug 2016 23:36:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BJBAAEcrpX/5tjdVtdHoMmgVKiUwUBAQQFAYEQAZFzgg+BfRSGCYEzOBQBAQEBAQEBAQFeJ4UMUk9ONIgxBAG8czGFY4ohhQ8Fk2yFXIkfhgACgWuHbCN9hFUCkDceNoFBURyBaFSGewEBAQ X-IPAS-Result: A2BJBAAEcrpX/5tjdVtdHoMmgVKiUwUBAQQFAYEQAZFzgg+BfRSGCYEzOBQBAQEBAQEBAQFeJ4UMUk9ONIgxBAG8czGFY4ohhQ8Fk2yFXIkfhgACgWuHbCN9hFUCkDceNoFBURyBaFSGewEBAQ X-IronPort-AV: E=Sophos;i="5.28,558,1464645600"; d="scan'208";a="163168221" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Aug 2016 05:36:21 +0200 Received: from [173.243.46.202] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1bbg29-0007lg-22; Mon, 22 Aug 2016 05:36:21 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bbg1v-0007RB-6k; Mon, 22 Aug 2016 06:36:07 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Sun, 21 Aug 2016 23:36:03 -0400 Message-Id: <1471836963-28548-1-git-send-email-berto@igalia.com> X-Mailer: git-send-email 2.8.1 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] commit: get the overlay node before manipulating the backing chain 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 , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The 'block-commit' command has a 'top' parameter to specify the topmost node from which the data is going to be copied. [E] <- [D] <- [C] <- [B] <- [A] In this case if [C] is the top node then this is the result: [E] <- [B] <- [A] [B] must be modified so its backing image string points to [E] instead of [C]. commit_start() takes care of reopening [B] in read-write mode, and commit_complete() puts it back in read-only mode once the operation has finished. In order to find [B] (the overlay node) we look for the node that has [C] (the top node) as its backing image. However in commit_complete() we're doing it after [C] has been removed from the chain, so [B] is never found and remains in read-write mode. This patch gets the overlay node before the backing chain is manipulated. Signed-off-by: Alberto Garcia --- block/commit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/commit.c b/block/commit.c index 553e18d..a02539b 100644 --- a/block/commit.c +++ b/block/commit.c @@ -83,7 +83,7 @@ static void commit_complete(BlockJob *job, void *opaque) BlockDriverState *active = s->active; BlockDriverState *top = blk_bs(s->top); BlockDriverState *base = blk_bs(s->base); - BlockDriverState *overlay_bs; + BlockDriverState *overlay_bs = bdrv_find_overlay(active, top); int ret = data->ret; if (!block_job_is_cancelled(&s->common) && ret == 0) { @@ -97,7 +97,6 @@ static void commit_complete(BlockJob *job, void *opaque) if (s->base_flags != bdrv_get_flags(base)) { bdrv_reopen(base, s->base_flags, NULL); } - overlay_bs = bdrv_find_overlay(active, top); if (overlay_bs && s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) { bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL); }