From patchwork Thu Nov 26 05:05:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 548919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E640E1402DD for ; Thu, 26 Nov 2015 16:09:03 +1100 (AEDT) Received: from localhost ([::1]:49199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1onl-00068x-Bi for incoming@patchwork.ozlabs.org; Thu, 26 Nov 2015 00:09:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1olx-0002BP-0o for qemu-devel@nongnu.org; Thu, 26 Nov 2015 00:07:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1olw-0007kv-5Q for qemu-devel@nongnu.org; Thu, 26 Nov 2015 00:07:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1olu-0007kX-C9; Thu, 26 Nov 2015 00:07:06 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id F32C2A1702; Thu, 26 Nov 2015 05:07:05 +0000 (UTC) Received: from fam-t430.redhat.com (vpn1-4-91.pek2.redhat.com [10.72.4.91]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAQ55ah6029554; Thu, 26 Nov 2015 00:07:00 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 26 Nov 2015 13:05:31 +0800 Message-Id: <1448514335-15988-12-git-send-email-famz@redhat.com> In-Reply-To: <1448514335-15988-1-git-send-email-famz@redhat.com> References: <1448514335-15988-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , Peter Lieven , Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini Subject: [Qemu-devel] [PATCH v3 11/15] vmdk: Return extent's file in bdrv_get_block_status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Fam Zheng --- block/vmdk.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index f5a56fd..b60a5af 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1265,6 +1265,7 @@ static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs, 0, 0); qemu_co_mutex_unlock(&s->lock); + index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num); switch (ret) { case VMDK_ERROR: ret = -EIO; @@ -1276,15 +1277,13 @@ static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs, ret = BDRV_BLOCK_ZERO; break; case VMDK_OK: - ret = BDRV_BLOCK_DATA; - if (extent->file == bs->file && !extent->compressed) { - ret |= BDRV_BLOCK_OFFSET_VALID | offset; - } - + ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; + ret |= (offset + (index_in_cluster << BDRV_SECTOR_BITS)) + & BDRV_BLOCK_OFFSET_MASK; + *file = extent->file->bs; break; } - index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num); n = extent->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors;