From patchwork Thu Jul 7 07:42:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reda Sallahi X-Patchwork-Id: 9217985 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 A4F8A607D9 for ; Thu, 7 Jul 2016 07:44:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ADE22877E for ; Thu, 7 Jul 2016 07:44:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F2A728786; Thu, 7 Jul 2016 07:44:16 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 7EAA92877E for ; Thu, 7 Jul 2016 07:44:15 +0000 (UTC) Received: from localhost ([::1]:38024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL3yo-0000xw-M6 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Jul 2016 03:44:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL3yI-0000ud-5l for qemu-devel@nongnu.org; Thu, 07 Jul 2016 03:43:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bL3yC-0007hB-6Z for qemu-devel@nongnu.org; Thu, 07 Jul 2016 03:43:41 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32937) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL3yB-0007h7-Vt; Thu, 07 Jul 2016 03:43:36 -0400 Received: by mail-wm0-x243.google.com with SMTP id n127so939032wme.0; Thu, 07 Jul 2016 00:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=VR/PQqGyu/K4Fu7I9+ufZHxo91ifPYT9v2VybkAHpSY=; b=oEJCPZMFzAYTpfBz193tjdp/jPXk/YtALfgqvOhOAg04ZEtHIV3hTDvf7XmGr0hBoV mrrh03dBdmHdiXCCSUSsQTi2LeFOn24UDFs/E/uJGaxN9JaQw2USKqtTu9G/c/pjbV7g N37RfX6v6xxlcQnfOB1zya+iwHJcjQxKHrq+3YBi4CXIHnhbQ2SmOsVSU3/PgsFv0+cw k+Fhr8KcMJLVwGH5oCilclK4nHg0eulj/QhrrwBvIJCxxWnWfn+XHef8levb29DlD0Qh lgWKf6rtd4MkQO/cHvLcobmoMARrJCmnaaNQ9z/BBWU5t+3w/4EH67GPPdn3G8SKpYns JwRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VR/PQqGyu/K4Fu7I9+ufZHxo91ifPYT9v2VybkAHpSY=; b=enp4tXs8FZkjRXuUXPFtGxy1QLZeTNCrERSlWs+hB8z2Ii/uCv/iNB0RHbIyl26u7J LHkiQM0qmoHqbmvG9KrNqd522HJPXwv8AfVsPpfcyY5OE5BaUwEguP94wtBneUV59l2f AmseQdJDbgDhTKFLneR1Yc101179Xbh9kuzds1muyx31FBiHGUM8hAgEoK1mFe+LOR39 0y3EXPt1len/mnfdkFndUJ03t2LWNkftUWoD4yIvDVQL35DI2GXozGLEN+UrZozOlj+R 3N31SwFCAvLZBgmaMCfN2B/W3peSrKuehsLVEyYWzRU18vvhfG7xpy11bD1gMsbc1WM5 owmg== X-Gm-Message-State: ALyK8tLaYCjdxuPMbISSdBo6n4mo1TFhkcDsWYAdHqhr1oCUM7wW4fIHY2qsjiS12WcJdQ== X-Received: by 10.194.188.16 with SMTP id fw16mr1198534wjc.38.1467877414880; Thu, 07 Jul 2016 00:43:34 -0700 (PDT) Received: from localhost.localdomain (ram94-2-82-66-69-246.fbx.proxad.net. [82.66.69.246]) by smtp.gmail.com with ESMTPSA id bh7sm796157wjb.22.2016.07.07.00.43.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2016 00:43:34 -0700 (PDT) From: Reda Sallahi To: qemu-devel@nongnu.org Date: Thu, 7 Jul 2016 09:42:21 +0200 Message-Id: <20160707074221.28541-1-fullmanet@gmail.com> X-Mailer: git-send-email 2.9.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH] vmdk: fix metadata write regression 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 , Reda Sallahi , Fam Zheng , 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 Commit "cde6361 vmdk: add bdrv_co_write_zeroes" causes a regression on writes. It writes metadata after every write instead of doing it only once for each cluster. vmdk_pwritev() writes metadata whenever m_data is set as valid so this patch sets m_data as valid only when we have a new cluster which hasn't been allocated before or a zero grain. Signed-off-by: Reda Sallahi --- block/vmdk.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index d73f431..1cbd487 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1202,13 +1202,6 @@ static int get_cluster_offset(BlockDriverState *bs, l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size; cluster_sector = le32_to_cpu(l2_table[l2_index]); - if (m_data) { - m_data->valid = 1; - m_data->l1_index = l1_index; - m_data->l2_index = l2_index; - m_data->l2_offset = l2_offset; - m_data->l2_cache_entry = &l2_table[l2_index]; - } if (extent->has_zero_grain && cluster_sector == VMDK_GTE_ZEROED) { zeroed = true; } @@ -1231,6 +1224,13 @@ static int get_cluster_offset(BlockDriverState *bs, if (ret) { return ret; } + if (m_data) { + m_data->valid = 1; + m_data->l1_index = l1_index; + m_data->l2_index = l2_index; + m_data->l2_offset = l2_offset; + m_data->l2_cache_entry = &l2_table[l2_index]; + } } *cluster_offset = cluster_sector << BDRV_SECTOR_BITS; return VMDK_OK;