From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byijj-0008MI-9w for qemu-devel@nongnu.org; Mon, 24 Oct 2016 13:08:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byiji-0000oM-AA for qemu-devel@nongnu.org; Mon, 24 Oct 2016 13:08:35 -0400 References: <1475232808-4852-1-git-send-email-vsementsov@virtuozzo.com> <1475232808-4852-13-git-send-email-vsementsov@virtuozzo.com> <0cb068bb-e625-ecb3-0078-b20828920619@redhat.com> <5ce110e0-f204-affb-897f-7c6bada6739f@virtuozzo.com> From: Max Reitz Message-ID: <8ed2ee67-cf67-a80f-902f-c40a1409a2cd@redhat.com> Date: Mon, 24 Oct 2016 19:08:24 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fQ0gLINPo4AQJNsC7JWlEpnliWTNpQx4f" Subject: Re: [Qemu-devel] [PATCH 12/22] qcow2-bitmap: add IN_USE flag List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, eblake@redhat.com, jsnow@redhat.com, famz@redhat.com, den@openvz.org, stefanha@redhat.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fQ0gLINPo4AQJNsC7JWlEpnliWTNpQx4f From: Max Reitz To: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, eblake@redhat.com, jsnow@redhat.com, famz@redhat.com, den@openvz.org, stefanha@redhat.com, pbonzini@redhat.com Message-ID: <8ed2ee67-cf67-a80f-902f-c40a1409a2cd@redhat.com> Subject: Re: [PATCH 12/22] qcow2-bitmap: add IN_USE flag References: <1475232808-4852-1-git-send-email-vsementsov@virtuozzo.com> <1475232808-4852-13-git-send-email-vsementsov@virtuozzo.com> <0cb068bb-e625-ecb3-0078-b20828920619@redhat.com> <5ce110e0-f204-affb-897f-7c6bada6739f@virtuozzo.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 24.10.2016 13:35, Vladimir Sementsov-Ogievskiy wrote: > 24.10.2016 13:32, Vladimir Sementsov-Ogievskiy =D0=BF=D0=B8=D1=88=D0=B5= =D1=82: >> 21.10.2016 22:58, Max Reitz =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >>> On 21.10.2016 17:34, Vladimir Sementsov-Ogievskiy wrote: >>>> 07.10.2016 22:44, Max Reitz =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >>>>> On 30.09.2016 12:53, Vladimir Sementsov-Ogievskiy wrote: >>>>>> This flag means that the bitmap is now in use by the software or >>>>>> was not >>>>>> successfully saved. In any way, with this flag set the bitmap data= >>>>>> must >>>>>> be considered inconsistent and should not be loaded. >>>>>> >>>>>> With current implementation this flag is never set, as we just rem= ove >>>>>> bitmaps from the image after loading. But it defined in qcow2 spec= >>>>>> and >>>>>> must be handled. Also, it can be used in future, if async schemes = of >>>>>> bitmap loading/saving are implemented. >>>>>> >>>>>> We also remove in-use bitmaps from the image on open. >>>>>> >>>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy >>>>>> >>>>>> --- >>>>>> block/qcow2-bitmap.c | 17 ++++++++++++++++- >>>>>> 1 file changed, 16 insertions(+), 1 deletion(-) >>>>> Don't you want to make use of this flag? It would appear useful to >>>>> me if >>>>> you just marked autoload bitmaps as in_use instead of deleting them= >>>>> from >>>>> the image when it's opened and then overwrite them when the image i= s >>>>> closed. >>>> And what is the use of it? >>> You don't need to free any bitmaps when opening the file, and you don= 't >>> need to allocate any new bitmap space when closing it. >> >> As bitmaps are sparce in file, I need to allocate new space when >> closing. Or free it... >=20 >=20 > Is it a real problem to reallocate space in qcow2? If so, to minimaze > allocations, I will have to make a list of clusters of in_use bitmaps o= n > close, and then save current bitmaps to these clusters (and allocated > some additional clusters, or free extra clusters). It's not a real problem, but it does take time, and I maintain that it's time it doesn't need to take because you can just use the in_use flag. I wouldn't worry about reusing clusters of other bitmaps. Of course we can do that later on in some optimization but not now. I just mean the basic case of some auto-loaded bitmap that is not being deleted while the VM is running and is just saved back to the image file once it is closed. I don't expect that users will always consume all of the auto-loaded bitmaps while the VM is active... > Also, if I don't free them on open, I'll have to free them on remove of= > bdrv dirty bitmap.. Yes, so? That takes time, but that is something the user will probably expect. I wouldn't expect opening of the file to take that time. Overall, it doesn't matter time-wise whether you free the bitmap data when opening the image file or when the dirty bitmap is actually deleted by the user or when the image file is closed. Just setting the single in_use flag for all of the auto-loaded bitmaps will basically not take any time. On the other hand, as soon as just a single auto-loaded bitmap survives a VM (or qemu-img) invocation, you will very, very likely safe at least some time because writing the bitmap to the disk can reuse at least some of the existing clusters. Max --fQ0gLINPo4AQJNsC7JWlEpnliWTNpQx4f Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEvBAEBCAAZBQJYDkAIEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQOEM B/4lmY/+PrHhPnVuzoijHYSygdhf/+6fasSMj4KELK95JpCHe3KA2icM1VlutDNd tCcY3tJFSBWUqqvTx3KDRhKtCLzReIb8t4v6XOTer50z1/g0akxfqxan1V2DZ8q9 JOsB0zgwTXFmNcmaei0fVr97dUtuxfQiY0Za1FTrOyUVCHsrtGrvyQ9sdWnQviSf eQzHUbcoFF5z3GsCvQjs2a3SymkzU+aTvAQgMytyBe1nTrYTkLSG2MrBLwpz8RKj wLsKGNtgJle326FqxrzoBp6TX6yinezTBClL9TsyjT8IXK8AnA1FpwSS5Xkr5Stu ptmxuKGbu9f8gJdjjUTXd6A4 =bJLL -----END PGP SIGNATURE----- --fQ0gLINPo4AQJNsC7JWlEpnliWTNpQx4f--