From patchwork Wed Oct 2 16:02:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 279800 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 25EBA2C00BA for ; Thu, 3 Oct 2013 02:03:24 +1000 (EST) Received: from localhost ([::1]:36879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VROtV-0006Gi-Rh for incoming@patchwork.ozlabs.org; Wed, 02 Oct 2013 12:03:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VROt7-0006Ga-Jk for qemu-devel@nongnu.org; Wed, 02 Oct 2013 12:03:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VROsz-00061y-63 for qemu-devel@nongnu.org; Wed, 02 Oct 2013 12:02:57 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:37862 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VROsy-00061a-Ql for qemu-devel@nongnu.org; Wed, 02 Oct 2013 12:02:49 -0400 Received: (qmail 21437 invoked by uid 89); 2 Oct 2013 16:02:46 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98/17927. hbedv: 8.2.12.126/7.11.105.158. spamassassin: 3.3.1. Clear:RC:1(195.62.97.28):SA:0(-1.7/5.0):. Processed in 10.603371 secs); 02 Oct 2013 16:02:46 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with SMTP; 2 Oct 2013 16:02:35 -0000 X-GL_Whitelist: yes Received: (qmail 31820 invoked from network); 2 Oct 2013 16:02:33 -0000 Received: from unknown (HELO ?172.20.250.15?) (pl@kamp.de@172.20.250.15) by submission.kamp.de with ESMTPS (DHE-RSA-CAMELLIA256-SHA encrypted) ESMTPA; 2 Oct 2013 16:02:33 -0000 Message-ID: <524C439A.6050003@kamp.de> Date: Wed, 02 Oct 2013 18:02:34 +0200 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Paolo Bonzini References: <1380723636-18456-1-git-send-email-pl@kamp.de> <20131002150614.GA14662@stefanha-thinkpad.redhat.com> <524C3828.9000706@redhat.com> In-Reply-To: <524C3828.9000706@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, stefanha@redhat.com, Stefan Hajnoczi , qemu-devel@nongnu.org, anthony@codemonkey.ws, ronniesahlberg@gmail.com Subject: Re: [Qemu-devel] [PATCHv4] block/get_block_status: avoid redundant callouts on raw devices 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 Am 02.10.2013 17:13, schrieb Paolo Bonzini: > Il 02/10/2013 17:06, Stefan Hajnoczi ha scritto: >> Sorry I didn't review this earlier but this flag looks hacky and I'm not >> confident about merging the patch yet. >> >> The patch makes me wonder if the raw_bsd driver should avoid calling >> bs->file itself: >> >> return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | >> (sector_num << BDRV_SECTOR_BITS); >> >> Let block.c:bdrv_co_get_block_status() call down into bs->file. >> >> The problem is then the protocol cannot report unallocated sectors with >> this approach. >> >> I think we want to preserve bs' offset while taking the other flags from >> bs->file (DATA, ZERO). > This would cause other changes. For example, a qcow2 with full metadata > preallocation (i.e. all L2 tables are there but it points to holes) > would not return DATA anymore. I think this is wrong, and especially a > change from the old is_allocated API. > > However, a variant on this idea could be to return > > BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | > (sector_num << BDRV_SECTOR_BITS); > > and then BDRV_BLOCK_RAW would mean "take DATA and ZERO from bs->file". Like this? diff --git a/block.c b/block.c index 93e113a..71fab1f 100644 --- a/block.c +++ b/block.c @@ -3146,6 +3146,10 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, *pnum = 0; return ret; } + + if (ret & BDRV_BLOCK_RAW) { + return bdrv_get_block_status(bs->file, sector_num, nb_sectors, pnum); + } if (!(ret & BDRV_BLOCK_DATA)) { if (bdrv_has_zero_init(bs)) { diff --git a/block/raw_bsd.c b/block/raw_bsd.c index d4ace60..308d605 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -62,7 +62,8 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { - return bdrv_get_block_status(bs->file, sector_num, nb_sectors, pnum); + return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | + (sector_num << BDRV_SECTOR_BITS); }