From patchwork Thu Jul 27 14:33:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9867027 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 5AB266035E for ; Thu, 27 Jul 2017 14:33:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CBFE2881A for ; Thu, 27 Jul 2017 14:33:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40CEE28821; Thu, 27 Jul 2017 14:33:56 +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 BBFE72881A for ; Thu, 27 Jul 2017 14:33:55 +0000 (UTC) Received: from localhost ([::1]:43369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dajrO-0008Ru-KF for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Jul 2017 10:33:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dajpQ-0007oI-3u for qemu-devel@nongnu.org; Thu, 27 Jul 2017 10:31:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dajpN-0005hY-1X for qemu-devel@nongnu.org; Thu, 27 Jul 2017 10:31:52 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:38450) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dajpM-0005gq-RX; Thu, 27 Jul 2017 10:31:48 -0400 Received: by mail-pg0-x241.google.com with SMTP id 125so7258656pgi.5; Thu, 27 Jul 2017 07:31:48 -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=Frh6VDB0/xAj1TJL449/st2nOhRT2c4sZdDlRf5/ir8=; b=pejaz//BlyvrzEsiKj3KHu195FFCB/AwkVr+qw1W1xVfUZyOXaoMKYVPM59T5INfCv TGlPSYi6dWc+Sdapz5bICxn3uM2lfwPmvJCwprcBotGQFYYhKRpVSED5phYe8cMgB5LL bw4/zq3J+9yKhzIBgqSxC8F5P8XDiCd0JwdBp0UBZAP6LoNZTwkkYUqsKa2BUCHCM655 GZriWw9VeFFFCUGJibbNuqduxwwcwDYqh6pBH46vgqtXVhErk6NHyjRuzmVh5o4Qbb9H A5qFsw57FLLvaMwD9Jk5WB/SQM4nbOyyM0f1XdOHaGK0/kpAo0w90SkdRharxIO0zisH Zg9Q== 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=Frh6VDB0/xAj1TJL449/st2nOhRT2c4sZdDlRf5/ir8=; b=d/UJLY+4pzFRiSLRLkjRrr7EgSEApmBjFncfq99XEFYSyBExbk00kdZhAM/Vo3Mssj ohEzRf3K/vihgbbyQlNZJIMiuBOxGEaPZuwOlBRH45b1NEGb8GVM71SReyKu0zvwcO6S QFZXCEeY3jjjdlXo05VOsCxF29BFdF6ZUfwpmym5Wg3ZxbckNoKDePk02g4d2/aHa0eS UGEzJh9zrA7p3b4JtSbt7dDSI6Cfe7RQ10A7jM5R4KKPgemFJF7psiWlREXA1EeglHYq 9N1/qeQrNwVkiU3GB7Oj1L8OZwXBSD7Zur4f6X62UeQQs+jC2eJkMCkMO4a5JiAFV4Rd gPEg== X-Gm-Message-State: AIVw112E4jSQGhb4YLXDhWuvN9AJvEadcwFnETEUs34+7jclE7rNfXeu iJay5jkBZEU5Ig== X-Received: by 10.98.135.141 with SMTP id i135mr2721291pfe.254.1501165907941; Thu, 27 Jul 2017 07:31:47 -0700 (PDT) Received: from linux.local ([27.251.197.195]) by smtp.gmail.com with ESMTPSA id y14sm32579540pfa.52.2017.07.27.07.31.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Jul 2017 07:31:47 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Thu, 27 Jul 2017 20:03:03 +0530 Message-Id: <1501165990-28033-2-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1501165990-28033-1-git-send-email-ashijeetacharya@gmail.com> References: <1501165990-28033-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:c05::241 Subject: [Qemu-devel] [PATCH v8 1/8] vmdk: Move vmdk_find_offset_in_cluster() to the top 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 Move the existing vmdk_find_offset_in_cluster() function to the top of the driver. Signed-off-by: Ashijeet Acharya Reviewed-by: Fam Zheng --- block/vmdk.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index a9bd22b..22be887 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -242,6 +242,18 @@ static void vmdk_free_last_extent(BlockDriverState *bs) s->extents = g_renew(VmdkExtent, s->extents, s->num_extents); } +static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, + int64_t offset) +{ + uint64_t extent_begin_offset, extent_relative_offset; + uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; + + extent_begin_offset = + (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; + extent_relative_offset = offset - extent_begin_offset; + return extent_relative_offset % cluster_size; +} + static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) { char *desc; @@ -1266,18 +1278,6 @@ static VmdkExtent *find_extent(BDRVVmdkState *s, return NULL; } -static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, - int64_t offset) -{ - uint64_t extent_begin_offset, extent_relative_offset; - uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; - - extent_begin_offset = - (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; - extent_relative_offset = offset - extent_begin_offset; - return extent_relative_offset % cluster_size; -} - static inline uint64_t vmdk_find_index_in_cluster(VmdkExtent *extent, int64_t sector_num) {