From patchwork Thu Jun 29 09:23:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9816275 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 276456035F for ; Thu, 29 Jun 2017 09:23:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BF3728653 for ; Thu, 29 Jun 2017 09:23:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FE3D286E5; Thu, 29 Jun 2017 09:23:40 +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 B4FDE28653 for ; Thu, 29 Jun 2017 09:23:39 +0000 (UTC) Received: from localhost ([::1]:37921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVfm-0004Ks-SC for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Jun 2017 05:23:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQVep-0004IB-GI for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQVeo-0006fP-Nq for qemu-devel@nongnu.org; Thu, 29 Jun 2017 05:22:39 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:36597) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dQVeo-0006f7-IB; Thu, 29 Jun 2017 05:22:38 -0400 Received: by mail-pg0-x243.google.com with SMTP id u36so11233582pgn.3; Thu, 29 Jun 2017 02:22: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=Frh6VDB0/xAj1TJL449/st2nOhRT2c4sZdDlRf5/ir8=; b=uQT0BINXt+KIhNh58+Su+rBl3znJnpbJiGX8sjqste3tqBBpzBmcZw6Ys0Dm5I2FxR VA5qCtQOBJNt4XoF+qd1HwK3vICcRnva0IwNJ7e71OXFr7HdvdUA87PMck829FqWFg1l lyVuPXxAdH+4gBo/h3+r4RV8SxoD/shfwRK60W3s1BsVet84pL+Gr2TJgx0f2wa1PYF9 tX/jWzVyFas8zhHXAm5Vx8EoIdefINOt+vFG0s7jQm9GcSxSDipsoAkiuzhKzUGAzvfs Bbv6/0+7uUx6RO+LQJuzuRQnIJN7agwm++yZIfQBfcqCrLr7Ct1MSefh+EHmoXMq4gmj tH1A== 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=KPIEGW+eZ+TK6ADXSYCaXBoLnXBSLp1q72+Z+8fqHVSF6+lwR+hu5ZPrxFG0mUFOkw sAaWOWeQPxxfUfpc8+rCCX7RhPKpCasYgIioPyL822qqdYy8G6SzjZ0aGql/Azq/Ld6r DNl4nqvNF6bDSbDmdlBBcqMCs0dUDu3p51rYby4XR5w6Yl6WNE3hEhfViDPsEBQN23th Czk/BEAWLI3OM+5vOt25xbt7OG8yV029kd7t1GJYrewCkku3x9MCAc4MTMGc9pUzQfIq ZKrDZAsgs6s7AYv3xyNvpGNn58tvdoKhRwhecXMz+TQpC3FWkwFJKq4Of3+OLV3AhQ7y Tldw== X-Gm-Message-State: AKS2vOwHZ+GV+kiQt6QEPseuv7PdEg6bC4sc/3t+BFtod0oqiKOEmpol gTonLJmPjG5UUA== X-Received: by 10.99.96.204 with SMTP id u195mr14520819pgb.125.1498728157757; Thu, 29 Jun 2017 02:22:37 -0700 (PDT) Received: from linux.local ([47.247.15.37]) by smtp.gmail.com with ESMTPSA id u9sm11031203pfg.127.2017.06.29.02.22.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 02:22:37 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Thu, 29 Jun 2017 14:53:34 +0530 Message-Id: <1498728221-23979-2-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1498728221-23979-1-git-send-email-ashijeetacharya@gmail.com> References: <1498728221-23979-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::243 Subject: [Qemu-devel] [PATCH v7 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) {