From patchwork Mon Jun 5 05:53:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9765591 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 310F9602B6 for ; Mon, 5 Jun 2017 05:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22B2723B24 for ; Mon, 5 Jun 2017 05:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16EF627F85; Mon, 5 Jun 2017 05:55:54 +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 ADDBD23B24 for ; Mon, 5 Jun 2017 05:55:53 +0000 (UTC) Received: from localhost ([::1]:59719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHkzY-0007dF-Qc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Jun 2017 01:55:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHkwU-00064B-5y for qemu-devel@nongnu.org; Mon, 05 Jun 2017 01:52:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHkwT-0007ha-CA for qemu-devel@nongnu.org; Mon, 05 Jun 2017 01:52:42 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:33962) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dHkwT-0007hR-6d; Mon, 05 Jun 2017 01:52:41 -0400 Received: by mail-pf0-x243.google.com with SMTP id w69so19511198pfk.1; Sun, 04 Jun 2017 22:52:41 -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=lHA6Cjkwlx4kFIlChjSYAeJaFSAZC+sYpEQAxLJW4u2R/SN5rWPzNuzJAwhqIDslAE 8dgSPR3/doY5uDQu1oREt5sYNGKv/7pIsfuSoCDu3445WUx7DBm4a4xq6vZDl3QHFj9e AMw+S/l6eOAc5yvrgbFzZVG6m4R/Jbj7zL0/d/v8nTJe6fkwGhOJIlojXdm2JsFyjfNb Dnq6AHcF1zBxYB1EE8G7iLNzHqHNVr9rPVOg/AzgL6pkFaWi/4uUrSDMoN0wAEsn4Nr7 hBkqbhNdfHWtuwbd4qE2pWZngXKecddC1RVHsVpEefjNkVeSrZeHnctkalEsbJ85UBlZ TwcQ== 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=k0PwRoWf2Tao636Cpwz7I1bN0+0MBa1tqGtgXuoS9skPWrysjgcHU4CjtHSBuSKHxC MzjDXKr44hEVimmUJAojCtDd6Dt4FMKXC2PbWoaTBGr665hppBbkiiyMQWK7rTC+TyJT c0wxfuKGLv8ZD6mbSMkuBB449ER7UMt/FUq6FIUNIagxjbRacikrMWNmKXvb8BrC40wW FkKNMymdVkl5PfeTWAhUNvQ8ixV5NsNXwQnCFEQEf9Ujh/Fc24HTWRCVKkp/981MKi0F i+Dpqov2wBln3tAhPKPZPdFONvq1YKVBNyrRzNxdPoPZLSB/cBtF9hsaY2OfylS/yd17 FGZA== X-Gm-Message-State: AODbwcAHUCFZenlIY23DPmB8AgtaPYMVefnMaErmFxiRaXkdAnuIVvJP 9d6ylMIscDoSLQ== X-Received: by 10.84.173.195 with SMTP id p61mr13010154plb.83.1496641960263; Sun, 04 Jun 2017 22:52:40 -0700 (PDT) Received: from linux.local ([47.247.8.225]) by smtp.gmail.com with ESMTPSA id s68sm961639pfj.33.2017.06.04.22.52.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Jun 2017 22:52:39 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Mon, 5 Jun 2017 11:23:20 +0530 Message-Id: <1496642007-8309-2-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::243 Subject: [Qemu-devel] [PATCH v5 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) {