From patchwork Sat Apr 22 05:13: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: 9694143 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 B33B86038D for ; Sat, 22 Apr 2017 05:16:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CAE028409 for ; Sat, 22 Apr 2017 05:16:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E77F2846F; Sat, 22 Apr 2017 05:16:24 +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 31F4528409 for ; Sat, 22 Apr 2017 05:16:24 +0000 (UTC) Received: from localhost ([::1]:34216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1nPD-0002N6-D9 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 22 Apr 2017 01:16:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1nMD-0007tg-C3 for qemu-devel@nongnu.org; Sat, 22 Apr 2017 01:13:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1nMC-0000RJ-4Y for qemu-devel@nongnu.org; Sat, 22 Apr 2017 01:13:17 -0400 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]:34151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d1nMB-0000RB-WD; Sat, 22 Apr 2017 01:13:16 -0400 Received: by mail-it0-x243.google.com with SMTP id 193so2408202itm.1; Fri, 21 Apr 2017 22:13:15 -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=YSO2IUwL1QYpxwO8rExQ3BZk8AmtADShVmAAx/g6HV3S6q+nJJJJNmaBdxLwR3QKlq GoMcRN9aEmMLyZHcvpBD7tGG/gF0oS99ydrafIjaN8ejjgW1fikBgVNaaGpHsgJ/m+4o PJ4pOit2TGJ+ttdDfRbOzp7RPAO0GSUiSugE9ViDsYOb1HEYC/4yVuOaVJ4L55I1Z6/A vgEpr9U7OHVxpQQc1b0JZud93GTZVqehH8Ku+B5etwi59ItgD+omdtM+4L3c9aEytlPT Hd8bAzAJFQ1gwkvZQWZjhH85U4rG9UD8NnCcHVWJo4edPxGuBJnwD48xEtvG5n9REDxx C5Bg== 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=e/rlJHFbhCeKBA3dZlNtwm4Oqpd3otRPE3Q76SPDibjCfEEcb7Znhl1ARnu36fNYi+ xHV4pHJX6ivoW9wDpBFRl3ik4VyQE5U/IXpC2eczJwYY+cqiwzkFB8uRPPfYDMD6eWEi CUo2tmmmC6/xRgSw7Ehbma3aJzU2yQlX4nKs+sPOQxtOGlQmipcHFGy2f5oZ3ZXRBxe4 j4X0pfDSsUVcbZUnYLuv0T+eJV9fHQC2QocNeo2PAQPeadP/phLYtFgoUT5ajnRKuAFg cKpo8JpYIyPwSZTiSS40mQ9cJJzUUd+vl9AFYuDXfiYM1WnC2vf159bGkqhlH6PCnTK5 mjVA== X-Gm-Message-State: AN3rC/52JF4Uuyomv5v/6CkOFz8Ke82L2bryKh1v0SSko0iJUFVlQFAB 1nzkWffclaaGHA== X-Received: by 10.84.254.4 with SMTP id b4mr17668619plm.64.1492837995338; Fri, 21 Apr 2017 22:13:15 -0700 (PDT) Received: from linux.local ([27.251.197.196]) by smtp.gmail.com with ESMTPSA id d82sm18780120pfl.124.2017.04.21.22.13.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Apr 2017 22:13:14 -0700 (PDT) From: Ashijeet Acharya To: famz@redhat.com Date: Sat, 22 Apr 2017 10:43:34 +0530 Message-Id: <1492838021-10538-2-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 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) {