From patchwork Sat Apr 22 05:13:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9694139 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 BEADF6038D for ; Sat, 22 Apr 2017 05:14:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B167A28409 for ; Sat, 22 Apr 2017 05:14:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A49122846F; Sat, 22 Apr 2017 05:14:30 +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 5784328409 for ; Sat, 22 Apr 2017 05:14:30 +0000 (UTC) Received: from localhost ([::1]:34203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1nNN-0008AH-FS for patchwork-qemu-devel@patchwork.kernel.org; Sat, 22 Apr 2017 01:14:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1nMG-0007vw-UL for qemu-devel@nongnu.org; Sat, 22 Apr 2017 01:13:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1nMF-0000SN-L5 for qemu-devel@nongnu.org; Sat, 22 Apr 2017 01:13:20 -0400 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]:35248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d1nMF-0000S7-Fq; Sat, 22 Apr 2017 01:13:19 -0400 Received: by mail-it0-x243.google.com with SMTP id e132so2404269ite.2; Fri, 21 Apr 2017 22:13:19 -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=y0aLdU8eyizcBISOMqtI7Bfk7gF3uIFfg+flRUveKjg=; b=WB2lV6lLM54cIcMBkoZCt8swz0KhDR7UO3DNiDE0cai0Pk7Ke02OkwPjV0TSNafyin f5RgPtwrLiIkIhndmVGq2Fqzxvx9LkjIT6PDwKmbRLxGF9Hd04GsVcyogFsi71Kcy2gZ vXHfV/c/naoZ8aYg6fOcBmlqlBYJvz+nrU9VYu5hJhIDDWsOZvcILHsoW64qG9FnGtjt WqqpowMtd6Q4XTnW3jMWANrR9Q+IM6CC8RaJbPx23iIcDD+3EmF7ZIQOohUZEOcmJkpO n1YjueUaWBWQvvfMwNM4FBWUJQyO1mrBf9ZMVRGqjnlHYCl5g4sXY5CmoGDw4ak0n7DJ 2TSw== 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=y0aLdU8eyizcBISOMqtI7Bfk7gF3uIFfg+flRUveKjg=; b=Nc2QE2LL5B8ivyhcRYnBRiwHjj5kuP2RGfjfbP103IbluCF6J/pV2UT9ndarw+vHBR 9/QOwNfGAK2NWlgKeVebHSUeixPw2xQwTmauujB1x0hsK7dvZjSo8kfzxT/9pHFRKLDD Sb+cWjdLO5AedqwboYcptV2fVwLI9kOZgHhIzCPPEzn+xqprMVYLvpA1WQLO1eJYDeC3 pD2u3zjjcG2/XeUrUTMjOk9iK2IfFOi2k0Na1NnnrlEG9UCZW0DnZjGkfUFk+V3SiXCJ LGrQ21gJfqu24JUYovSpbZ1wbGgICz+nyiznKU5tai46CHahHbu9cZWzHTU0CdLa9CAq V0jA== X-Gm-Message-State: AN3rC/4tdDFOQ8JkGsl1sXg5dwVXspWfT/aPL71jz20itKbzN85rELZr ZHhA+xujbzbCYw== X-Received: by 10.84.229.71 with SMTP id d7mr19923728pln.92.1492837999005; Fri, 21 Apr 2017 22:13:19 -0700 (PDT) Received: from linux.local ([27.251.197.196]) by smtp.gmail.com with ESMTPSA id d82sm18780120pfl.124.2017.04.21.22.13.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Apr 2017 22:13:18 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Sat, 22 Apr 2017 10:43:35 +0530 Message-Id: <1492838021-10538-3-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1492838021-10538-1-git-send-email-ashijeetacharya@gmail.com> References: <1492838021-10538-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:4001:c0b::243 Subject: [Qemu-devel] [PATCH v4 2/8] vmdk: Rename get_whole_cluster() to vmdk_perform_cow() 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 Rename the existing function get_whole_cluster() to vmdk_perform_cow() as its sole purpose is to perform COW for the first and the last allocated clusters if needed. Signed-off-by: Ashijeet Acharya Reviewed-by: Fam Zheng --- block/vmdk.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 22be887..73ae786 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1028,8 +1028,8 @@ static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp) } } -/** - * get_whole_cluster +/* + * vmdk_perform_cow * * Copy backing file's cluster that covers @sector_num, otherwise write zero, * to the cluster at @cluster_sector_num. @@ -1037,13 +1037,18 @@ static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp) * If @skip_start_sector < @skip_end_sector, the relative range * [@skip_start_sector, @skip_end_sector) is not copied or written, and leave * it for call to write user data in the request. + * + * Returns: + * VMDK_OK: on success + * + * VMDK_ERROR: in error cases */ -static int get_whole_cluster(BlockDriverState *bs, - VmdkExtent *extent, - uint64_t cluster_offset, - uint64_t offset, - uint64_t skip_start_bytes, - uint64_t skip_end_bytes) +static int vmdk_perform_cow(BlockDriverState *bs, + VmdkExtent *extent, + uint64_t cluster_offset, + uint64_t offset, + uint64_t skip_start_bytes, + uint64_t skip_end_bytes) { int ret = VMDK_OK; int64_t cluster_bytes; @@ -1244,7 +1249,7 @@ static int get_cluster_offset(BlockDriverState *bs, * This problem may occur because of insufficient space on host disk * or inappropriate VM shutdown. */ - ret = get_whole_cluster(bs, extent, cluster_sector * BDRV_SECTOR_SIZE, + ret = vmdk_perform_cow(bs, extent, cluster_sector * BDRV_SECTOR_SIZE, offset, skip_start_bytes, skip_end_bytes); if (ret) { return ret;