From nobody Sun Feb 8 10:41:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496642297705880.9419308276058; Sun, 4 Jun 2017 22:58:17 -0700 (PDT) Received: from localhost ([::1]:59738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHl1s-0002DX-Dk for importer@patchew.org; Mon, 05 Jun 2017 01:58:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHkwo-0006Ir-6W for qemu-devel@nongnu.org; Mon, 05 Jun 2017 01:53:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHkwn-000823-FZ for qemu-devel@nongnu.org; Mon, 05 Jun 2017 01:53:02 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:33997) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dHkwn-00081c-9v; Mon, 05 Jun 2017 01:53:01 -0400 Received: by mail-pf0-x244.google.com with SMTP id w69so19512233pfk.1; Sun, 04 Jun 2017 22:53:01 -0700 (PDT) Received: from linux.local ([47.247.8.225]) by smtp.gmail.com with ESMTPSA id s68sm961639pfj.33.2017.06.04.22.52.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Jun 2017 22:52:59 -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=ZHvK2Vys1FDOQRWCQbXjjaMPx12sSGaapnbVk2Pi7bM=; b=DHynSDxPy2RKuTamuS/A8DrORL8CVhy032UNkGdnoAgB5o37SECpYoTWPR6SQa/3Wm OHUnuBQ36rUpaJsKl93ziUQuy5GiwR5QGu0nfFrwbyjYkAi9qTrdpUtCkKEzL+gC2IRH +FjxEZDcDzQKdENGcvabd8YW7z7B3e749PPfHdMMVNVYeZ+2NvVxcfceqdS0rTtLAd4i 9sui505D5YqIPcIDhgHWPkv9Mz4BEb+RGfNUaxEeHUZLp6gCUYKk8p+QA+T42kSLC6MZ I608qSfV/1xVqiRfeE3AnMs7t2lqyOxcq4fEdeT6diIRs7IBbKvJY1AVPEvFzBkMjMh5 DrqA== 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=ZHvK2Vys1FDOQRWCQbXjjaMPx12sSGaapnbVk2Pi7bM=; b=DdeY+XVXCjU+rtvjGmFdp/HQwuFqeBJ6rTVFXeWQW4FnL3OHAAWu2Y4fUA11BG0MaA CMASiUg68D9OPf49693/UzUMBme39eNfDIRMCdjb2lv41W7ygDxpdBjTguwCDCBc+1ER WicGOq1nFgMFBOT5uIXoGtK8sKfqGWN0w2S8sT6d/3wDRcHuKLiJdG+Oz3uu3qczrNOX Os8cWqdi4JVkYXfT6WQI2GIVZMJv4ZVJEhsDRLDvnZhxgmGeJsWn36/9vcZ6mnD4JnbY ysEkBvY9Otnsc7kojW/xl7A/nJ6aM7J4FGDrCgu5m1ndZXjU7pe8e/wyIpGOD0hFXKIV AWPQ== X-Gm-Message-State: AODbwcC9anvFJiEHDl+l970heEam065EgtSdAWRSfirogEESKqIU+6Xy 8dWuFxHF4omcSbztSnU= X-Received: by 10.84.177.131 with SMTP id x3mr13396888plb.39.1496641980344; Sun, 04 Jun 2017 22:53:00 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Mon, 5 Jun 2017 11:23:24 +0530 Message-Id: <1496642007-8309-6-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1496642007-8309-1-git-send-email-ashijeetacharya@gmail.com> References: <1496642007-8309-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v5 5/8] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Fam Zheng --- block/vmdk.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 5647f53..fe2046b 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1624,6 +1624,7 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_= t offset, uint64_t cluster_offset; uint64_t bytes_done =3D 0; VmdkMetaData m_data; + uint64_t extent_end; =20 if (DIV_ROUND_UP(offset, BDRV_SECTOR_SIZE) > bs->total_sectors) { error_report("Wrong offset: offset=3D0x%" PRIx64 @@ -1637,9 +1638,17 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64= _t offset, if (!extent) { return -EIO; } + extent_end =3D extent->end_sector * BDRV_SECTOR_SIZE; + offset_in_cluster =3D vmdk_find_offset_in_cluster(extent, offset); - n_bytes =3D MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_SIZE - - offset_in_cluster); + + /* truncate n_bytes to first cluster because we need to perform CO= W */ + if (offset_in_cluster > 0) { + n_bytes =3D MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_S= IZE + - offset_in_cluster); + } else { + n_bytes =3D MIN(bytes, extent_end - offset); + } =20 ret =3D vmdk_get_cluster_offset(bs, extent, &m_data, offset, !(extent->compressed || zeroed), --=20 2.6.2