From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZHmd-0006cM-5L for qemu-devel@nongnu.org; Thu, 24 Oct 2013 06:04:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZHmY-0004Uv-8o for qemu-devel@nongnu.org; Thu, 24 Oct 2013 06:04:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZHmY-0004Uo-0u for qemu-devel@nongnu.org; Thu, 24 Oct 2013 06:04:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9OA4jHb019134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Oct 2013 06:04:45 -0400 Message-ID: <5268F0BB.1010604@redhat.com> Date: Thu, 24 Oct 2013 11:04:43 +0100 From: Eric Blake MIME-Version: 1.0 References: <1382557241-23117-1-git-send-email-mreitz@redhat.com> In-Reply-To: <1382557241-23117-1-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GBeVe6TnjBfVFQJddCOMemlH8DPXtbo2D" Subject: Re: [Qemu-devel] [PATCH] qcow2: Flush image after creation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GBeVe6TnjBfVFQJddCOMemlH8DPXtbo2D Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/23/2013 08:40 PM, Max Reitz wrote: > Opening the qcow2 image with BDRV_O_NO_FLUSH prevents any flushes durin= g > the image creation. This means that the image has not yet been flushed > to disk when qemu-img create exits. This flush is delayed until the nex= t > operation on the image involving opening it without BDRV_O_NO_FLUSH and= > closing (or directly flushing) it. For large images and/or images with = a > small cluster size and preallocated metadata, this flush may take a > significant amount of time and may occur unexpectedly. >=20 > Reopening the image without BDRV_O_NO_FLUSH right before the end of > qcow2_create2() results in preponing the potentially costly flush into s/preponing/hoisting/ > the image creation, which is expected to take some time (whereas > successive image operations may be not). >=20 > Signed-off-by: Max Reitz > --- > block/qcow2.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) Reviewed-by: Eric Blake > - ret =3D 0; > + bdrv_close(bs); > + > + /* Reopen the image without BDRV_O_NO_FLUSH to flush it before ret= urning */ > + ret =3D bdrv_open(bs, filename, NULL, > + BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err); I would probably have indented as: ret =3D bdrv_open(bs, filename, NULL, BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err); but it's trivial enough that I'm also fine with your choice. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GBeVe6TnjBfVFQJddCOMemlH8DPXtbo2D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSaPC7AAoJEKeha0olJ0NqsBEH/jIVGfASBpFCt3Z4Va4NgCdW U05E17i+Vr++4FQ9IB6zg4dcJDs++m1hoBPpVeenBZ83hfCU/SZAj6LwUnJmFMhN PZwMhBPNLu1B1Fhq8hcD4j0PRSczXWVCwc6pxB998teXB467axd0RbXsMj4v8z8M N5ykIk5o1dvWLhmCDnTy9isgXmRa+MqYPpmebTlOLkeXfsldQ5tIsioJFo9NZuRr SHGO/9jvy9WEEotI9T7gH7Ol2brfA4eOuQ22J60tyYyNrIW6J4h+jEGRVdkJrUoL QzNo2U0Hum7KMAxl7yHGt38yqcbDkpOMa++uyW0v1OoVKtP2RZ5FzzkXa6EpVng= =BFVx -----END PGP SIGNATURE----- --GBeVe6TnjBfVFQJddCOMemlH8DPXtbo2D--