From patchwork Thu Jul 7 08:42:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reda Sallahi X-Patchwork-Id: 9218469 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 751EE6048B for ; Thu, 7 Jul 2016 08:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67E96287B7 for ; Thu, 7 Jul 2016 08:43:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C2DB287B9; Thu, 7 Jul 2016 08:43:38 +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 F3538287B7 for ; Thu, 7 Jul 2016 08:43:37 +0000 (UTC) Received: from localhost ([::1]:38230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL4uH-00087E-7O for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Jul 2016 04:43:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL4tt-00085q-3z for qemu-devel@nongnu.org; Thu, 07 Jul 2016 04:43:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bL4tp-0002vg-13 for qemu-devel@nongnu.org; Thu, 07 Jul 2016 04:43:13 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL4to-0002vI-RY; Thu, 07 Jul 2016 04:43:08 -0400 Received: by mail-wm0-x243.google.com with SMTP id a66so3783080wme.2; Thu, 07 Jul 2016 01:43:07 -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=+18KnqHOPc1obLWgriOHTOjEoNhIjMbivhLLEix96u8=; b=aKpLmis+bM2UJtdMqMWaTzFhsp6ELjBjyXvZqNebHe0ixb5lCGmKVLfFoU3Gq97SLh ji8Cf8uQU0/8paByT7Ra84PruC0WQ/f1ooFkf+hpZfeXRX0HdV+KkO7qZOf7TTBT0NAD zjn69MYu8nCSNx+Hqly1Kwjot1Phka07hp3esc9uJKPTdq4vjYAD2IQhWT4SOdTw3VVk RYflmpkC7TSpiHu78McYjOLnQaIi1kmgfB5Jb8XfhngYqiz7UOG8HY5HtGzUENrcDzDG aOgoL4Rc9tbVjDrPYKjbPdUUfZZ/E7eRiND1fJPYpSvCBM92SGESfjnHX6SsG6njQnE9 VKfA== 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=+18KnqHOPc1obLWgriOHTOjEoNhIjMbivhLLEix96u8=; b=PwsK8SBYA7WfG/djkI1k1HwFGvQ5UQo+2Jd6Avd3YCEzLCu/7LEawl5YJ0kGWwdzHl HUVmeK5JhUMwQk1HAJ/4TxwuKOG5kxwZD5e/dDZa67HxHWy6C1UtnBniYED1U2uuVK3B RWGHeKYOey5eq7FVt90bNr961iNRCp1WKG5AkVi8uHy0M8yZJlMS/kZhbTpKvwMxIgUd qA0KxPOjqBTS9H2nBfKUtrLFpvJwa6G2A91iKbfwr6YKRFiDxiOsBbDhl4bpyze3KTwq gawf2fKVMipSRE2BFYUwD0vOflayL7YjZ+eRDYssJRahjody1TqdiY/GcP4t6C6Rs1gd 7+8A== X-Gm-Message-State: ALyK8tLLs09R7Qjr8K8sf5VJQqc+NL3DpNk64UVcEc1G6gK6rxqKKBKlQz6nCjG3Qnh3bA== X-Received: by 10.194.75.196 with SMTP id e4mr24538596wjw.44.1467880986942; Thu, 07 Jul 2016 01:43:06 -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 j2sm6111808wjz.15.2016.07.07.01.43.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2016 01:43:06 -0700 (PDT) From: Reda Sallahi To: qemu-devel@nongnu.org Date: Thu, 7 Jul 2016 10:42:49 +0200 Message-Id: <20160707084249.29084-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 v2] 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 "cdeaf1f 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 Reviewed-by: Fam Zheng --- v2: Corrected the commit id referenced in the commit message. 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;