From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDWXI-00013m-9G for qemu-devel@nongnu.org; Thu, 07 Mar 2013 03:50:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDWXG-0005Ly-5w for qemu-devel@nongnu.org; Thu, 07 Mar 2013 03:50:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDWXF-0005Le-T8 for qemu-devel@nongnu.org; Thu, 07 Mar 2013 03:50:46 -0500 Date: Thu, 7 Mar 2013 09:50:38 +0100 From: Kevin Wolf Message-ID: <20130307085038.GB2536@dhcp-200-207.str.redhat.com> References: <51378200.5010705@dlhnet.de> <513785A0.1010001@redhat.com> <20130306181454.GB3743@localhost.localdomain> <51378B97.2000709@redhat.com> <20130306184800.GB22782@localhost.localdomain> <51379304.50307@dlhnet.de> <5137A964.5020803@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5137A964.5020803@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/7] block: only force IO completion in .bdrv_truncate if we are shrinking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: sw@weilnetz.de, Jeff Cody , Peter Lieven , qemu-devel@nongnu.org, stefanha@redhat.com Am 06.03.2013 um 21:39 hat Paolo Bonzini geschrieben: > Il 06/03/2013 20:03, Peter Lieven ha scritto: > > Am 06.03.2013 19:48, schrieb Jeff Cody: > >> On Wed, Mar 06, 2013 at 07:31:51PM +0100, Paolo Bonzini wrote: > >>> Il 06/03/2013 19:14, Jeff Cody ha scritto: > >>>> QCOW breaks with it using a normal raw posix file as a device. As a > >>>> test: qemu-img create -f qcow test.qcow 5G. Now run qemu with that > >>>> drive mounted, and try to partition and format it. QEMU now asserts. > >>>> > >>>> The nicety of being able to using truncate during a write call, > >>>> especially for VHDX (which can have relatively large block/cluster > >>>> sizes), so to grow the file sparsely in a dynamically allocated file. > >>> > >>> Perhaps we need two APIs, "truncate" and "revalidate". > >>> > >>> Truncate should be a no-op if (!bs->growable). > >>> > >>> Revalidate could be called by the block_resize monitor command with no > >>> size specified. > >>> > >>> Paolo > >> > >> I think that is a good solution. Is it better to have "truncate" and > >> "revalidate", or "truncate" and "grow", with grow being a subset of > >> truncate, with fewer restrictions? There may still be operations > >> where it is OK to grow a file, but not OK to shrink it. What semantics would the both operations have? Is truncate the same as it used to be? I don't really understand what "revalidate" would do, it sounds like a read-only operation from its name? > > Or as a first step: > > > > a) Call brdv_drain_all() only if the device is shrinked (independently of !bs->growable) > > b) Call brdv_drain_all() inside iscsi_truncate() because it is a special requirement there > > c) Fix the value of bs->growable for all drivers > > Let's start from (c). bdrv_file_open sets bs->growable = 1. I think it > should be removed and only the file protocol should set it. This is probably right. > Then we can add bdrv_revalidate and, for block_resize, call > bdrv_revalidate+bdrv_truncate. For bs->growable = 0 && > !bs->drv->bdrv_truncate, bdrv_truncate can just check that the actual > size is the same or bigger as the one requested, and fail otherwise. This one not so much. bs->growable does not mean that you can use bdrv_truncate. It rather means that you may write beyond the end of the file even without truncating it first. Mabye bs->auto_grow would be a better for it. So bs->growable == true implies that bdrv_truncate() should be allowed as well, because obviously changing the BDS size is possbile, but it's not true the other way round. Kevin