From patchwork Wed Sep 14 15:52:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9331931 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 7764F607FD for ; Wed, 14 Sep 2016 16:08:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68F672A19D for ; Wed, 14 Sep 2016 16:08:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DD472A19F; Wed, 14 Sep 2016 16:08:22 +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 378792A19D for ; Wed, 14 Sep 2016 16:08:20 +0000 (UTC) Received: from localhost ([::1]:57098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkCjT-0005LN-8c for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Sep 2016 12:08:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkCVW-0002b5-Uw for qemu-devel@nongnu.org; Wed, 14 Sep 2016 11:53:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkCVV-0008Mj-Hg for qemu-devel@nongnu.org; Wed, 14 Sep 2016 11:53:54 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:22256 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkCVV-0008Lq-A3; Wed, 14 Sep 2016 11:53:53 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BxBAD9cdlX/5tjdVtdHAEBBAEBCgEBgzoBAQEBAR5XfI0zlXIBAQEBAQUBgRIBj1eCL4IPggMchgICgU84FAECAQEBAQEBAV4nhGICBCdSED8SPBsZiE4BvDUBAQgnhWmCSYdahRAFjyGKR4YlgwKGLYI8hyWGAUiQDh42hGxthyEBAQE X-IPAS-Result: A2BxBAD9cdlX/5tjdVtdHAEBBAEBCgEBgzoBAQEBAR5XfI0zlXIBAQEBAQUBgRIBj1eCL4IPggMchgICgU84FAECAQEBAQEBAV4nhGICBCdSED8SPBsZiE4BvDUBAQgnhWmCSYdahRAFjyGKR4YlgwKGLYI8hyWGAUiQDh42hGxthyEBAQE X-IronPort-AV: E=Sophos;i="5.30,334,1470693600"; d="scan'208";a="172286377" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2016 17:52:42 +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 1bkCUL-0004ln-HH; Wed, 14 Sep 2016 17:52:41 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bkCU3-0005Y8-0X; Wed, 14 Sep 2016 18:52:23 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 14 Sep 2016 18:52:18 +0300 Message-Id: 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 5/7] block: Don't queue the same BDS twice in bdrv_reopen_queue_child() 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, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP bdrv_reopen_queue_child() assumes that a BlockDriverState is never added twice to BlockReopenQueue. That's however not the case: commit_start() adds 'base' (and its children) to a new reopen queue, and then 'overlay_bs' (and its children, which include 'base') to the same queue. The effect of this is that the first set of options is ignored and overriden by the second. We fixed this by swapping the order in which both BDSs were added to the queue in 3db2bd5508c86a1605258bc77c9672d93b5c350e. This patch checks if a BDS is already in the reopen queue and keeps its options. Signed-off-by: Alberto Garcia Reviewed-by: Kevin Wolf --- block.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index cf9c513..57f4b2c 100644 --- a/block.c +++ b/block.c @@ -1874,6 +1874,13 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue, options = qdict_new(); } + /* Check if this BlockDriverState is already in the queue */ + QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) { + if (bs == bs_entry->state.bs) { + break; + } + } + /* * Precedence of options: * 1. Explicitly passed in options (highest) @@ -1894,7 +1901,11 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue, } /* Old explicitly set values (don't overwrite by inherited value) */ - old_options = qdict_clone_shallow(bs->explicit_options); + if (bs_entry) { + old_options = qdict_clone_shallow(bs_entry->state.explicit_options); + } else { + old_options = qdict_clone_shallow(bs->explicit_options); + } bdrv_join_options(bs, options, old_options); QDECREF(old_options); @@ -1933,8 +1944,13 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue, child->role, options, flags); } - bs_entry = g_new0(BlockReopenQueueEntry, 1); - QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); + if (!bs_entry) { + bs_entry = g_new0(BlockReopenQueueEntry, 1); + QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); + } else { + QDECREF(bs_entry->state.options); + QDECREF(bs_entry->state.explicit_options); + } bs_entry->state.bs = bs; bs_entry->state.options = options;