From patchwork Mon Jun 5 07:52:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9765675 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 100C460364 for ; Mon, 5 Jun 2017 07:56:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0279427480 for ; Mon, 5 Jun 2017 07:56:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA1D827968; Mon, 5 Jun 2017 07:56:03 +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 93A8827480 for ; Mon, 5 Jun 2017 07:56:03 +0000 (UTC) Received: from localhost ([::1]:60131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHmrq-00064J-HB for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Jun 2017 03:56:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHmqY-00063D-QU for qemu-devel@nongnu.org; Mon, 05 Jun 2017 03:54:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHmqX-0002Sj-Rz for qemu-devel@nongnu.org; Mon, 05 Jun 2017 03:54:42 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:36819) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dHmqX-0002Rs-MC; Mon, 05 Jun 2017 03:54:41 -0400 Received: by mail-pg0-x244.google.com with SMTP id v18so5611592pgb.3; Mon, 05 Jun 2017 00:54: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=BkZ1D9UUO5Zn4yGFmqFglamEdhGMXkZj0BULc5jtpMPFirHd+phSQSnBEqGDDodg/z 8jRR9UEiHQACNzhWUW+llAm3oJmEki6orGcIYxaGdcVdWKAf1M0mjFTBYWDaytCFWxPo U/iWoSRRwqlFi0Jq87SrAYBJGRzvHjV2GkArBvAx1Uq1QcUvK/6bh28p5CKqT4hRFgB5 jviLmJol0TZboOUv94UAazbf90DPHpPCOc9lipgDmnEYYyg1AIYsTVys3Xu5DUF3shIV Fn3EcremxsHYDSC+auLQzToizpRcGxpLwUYGyy1/dLbBkOsJR7OHjnV7JGjF+U0zRIGO rxww== 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=S6fAwaeFUbbvGY36QkxyfsoTda2jeoObNzrEiXVl9Dkh2wjJ5qLdPi8oIDXyjYTVP1 tkW6gmpDSGnMEhj4D/tVf5Hsxj0Yt6CZKeqF/YCnWXJot2xadAZwC9vmrQc1YokCOv1R tXccUOMIOLvXPf9t4wMzd9cgkswMq+3pl0V/fW4CmSzMPfk2+A1Vf0678H/85/29NYru Ws/gsHHpr9RCNePpe/vd6KusLtoWss/Ui5/bRSXQR11fJYEq5UmWGVnirN+RJcZ6n+eF vPaTWl7dBsjWhfTfjjjluXUzjiU65abwLrMnpKr3IjgyEG7sKkZn7NSS+gmTYN2mrdbG 7aHg== X-Gm-Message-State: AODbwcBMOeKOZmvNj6P16iskdX86eNql5z68eD9FjiJTiphKAvWNz/aM L/ydR4bYynY1ag== X-Received: by 10.98.69.68 with SMTP id s65mr19288933pfa.178.1496649280724; Mon, 05 Jun 2017 00:54:40 -0700 (PDT) Received: from linux.local ([47.247.14.139]) by smtp.gmail.com with ESMTPSA id j71sm11775537pge.63.2017.06.05.00.54.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Jun 2017 00:54:40 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Mon, 5 Jun 2017 13:22:45 +0530 Message-Id: <1496649172-26982-2-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1496649172-26982-1-git-send-email-ashijeetacharya@gmail.com> References: <1496649172-26982-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::244 Subject: [Qemu-devel] [PATCH v6 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) {