From patchwork Sat Apr 1 14:44:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9658067 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 6F789602BC for ; Sat, 1 Apr 2017 14:48:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66FC9285E7 for ; Sat, 1 Apr 2017 14:48:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BCA1285ED; Sat, 1 Apr 2017 14:48:14 +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=-5.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, 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 05D93285E7 for ; Sat, 1 Apr 2017 14:48:14 +0000 (UTC) Received: from localhost ([::1]:51698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuKK5-0008Ii-4f for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Apr 2017 10:48:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuKGd-00066y-KH for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:44:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuKGc-000448-Ol for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:44:39 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34726) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuKGc-00043n-JW; Sat, 01 Apr 2017 10:44:38 -0400 Received: by mail-pf0-x242.google.com with SMTP id o126so4243862pfb.1; Sat, 01 Apr 2017 07:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lY72x0MPqywAOJgpjEJBmkhKmQAY3I2IM26F2Jh4iT0=; b=HPYRuDwAchGf3y+uoX5V9sTl5fRirOXrIJcdlEP67oQrGnp40tgtTR1qn6s94MLdLD /ujwBITujhuQvdOE7eOot11igOTtxZsj2BwUrRuFwQKpbGnYbqUkt4OHA0nEfdOMFTHR o/7xI4iue/VV9XtPxuvamA2n/KAp0+RDMoaFB1S8ryO0+tMfOZgSmaucNQLCcA+i5J1U F3SY/d7Q9fCPnKu/I7fzNjPtVMuWNv9k3KXBBuH7eiYvjWEr03bHktgE3m3FsaDcppg1 hDJxj2MlXBQlf+PvHIZSUtb4jwuEA2TXKaNAvfxLTPRjGQAvUhiT27YzUy8sL7TJ0c/T L+zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lY72x0MPqywAOJgpjEJBmkhKmQAY3I2IM26F2Jh4iT0=; b=m/lsonU/4IoeGaDfHkbdxnw/hUB8EM7XCdh0mCa50jbVp1Ih5gVx11LjnIvUochVzo GUevP9e03/OW+FCEijlebHPr9F881MVkJ3xxuZMlW6g/eUIfK4qm6ECot2+5qFde3PA0 exozHATfnLUhskEOm2hDDaZZRFQ3WVgjYNkrZpqhoYhOhN6SveVC0iqJR60FU2PUBvUY ats7ehXwolNWOqY0aSDmp62+l90wPmSVbYf0m9CMgd7s8PL3tEGaLSOk9luwc8FVQiRH Uik3eYTQKIOKQZSSKAwNLRWUiwrWaHYMieUKs8ZqWjQMIuqONptvtBhXUI/MYVWrVcCb zdOA== X-Gm-Message-State: AFeK/H04zDcM1RUzL8cESoSnZ6xc3AGQmWguuj2DuvoPYnZRWECh+9VLl77iStXnv7gG1Q== X-Received: by 10.98.138.193 with SMTP id o62mr7283997pfk.230.1491057877648; Sat, 01 Apr 2017 07:44:37 -0700 (PDT) Received: from linux.local ([27.251.197.196]) by smtp.gmail.com with ESMTPSA id h14sm9618461pgn.64.2017.04.01.07.44.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Apr 2017 07:44:37 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Sat, 1 Apr 2017 20:14:37 +0530 Message-Id: <1491057878-27868-6-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1491057878-27868-1-git-send-email-ashijeetacharya@gmail.com> References: <1491057878-27868-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3 5/6] vmdk: Set maximum bytes allocated in one cycle 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: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@gmail.com, qemu-devel@nongnu.org, mreitz@redhat.com, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Set the maximum bytes allowed to get allocated at once to be not more than the extent size boundary to handle writes at two separate extents appropriately. Signed-off-by: Ashijeet Acharya --- block/vmdk.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index a8babd7..9456ddd 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1767,6 +1767,7 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_t offset, int64_t offset_in_cluster, n_bytes; uint64_t cluster_offset; uint64_t bytes_done = 0; + uint64_t extent_size; VmdkMetaData m_data; uint32_t total_alloc_clusters = 0; @@ -1782,9 +1783,17 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_t offset, if (!extent) { return -EIO; } + extent_size = extent->end_sector * BDRV_SECTOR_SIZE; + offset_in_cluster = vmdk_find_offset_in_cluster(extent, offset); - n_bytes = MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_SIZE - - offset_in_cluster); + + /* truncate n_bytes to first cluster because we need to perform COW */ + if (offset_in_cluster > 0) { + n_bytes = MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_SIZE + - offset_in_cluster); + } else { + n_bytes = MIN(bytes, extent_size - offset); + } ret = vmdk_alloc_cluster_offset(bs, extent, &m_data, offset, !(extent->compressed || zeroed),