From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcZNJ-0003CQ-LI for qemu-devel@nongnu.org; Fri, 10 Oct 2014 08:32:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcZN7-00026o-I4 for qemu-devel@nongnu.org; Fri, 10 Oct 2014 08:32:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcZN7-00026H-A0 for qemu-devel@nongnu.org; Fri, 10 Oct 2014 08:32:37 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9ACWadb027200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 10 Oct 2014 08:32:36 -0400 Message-ID: <5437D1E3.4070302@redhat.com> Date: Fri, 10 Oct 2014 06:32:35 -0600 From: Eric Blake MIME-Version: 1.0 References: <1409088987-17207-1-git-send-email-mreitz@redhat.com> <1409088987-17207-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1409088987-17207-4-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gSRfJSnginnfdDfJaR7GQSBpcDKvJ1xaW" Subject: Re: [Qemu-devel] [PATCH v12 03/14] qcow2: Optimize bdrv_make_empty() 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) --gSRfJSnginnfdDfJaR7GQSBpcDKvJ1xaW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/26/2014 03:36 PM, Max Reitz wrote: > bdrv_make_empty() is currently only called if the current image > represents an external snapshot that has been committed to its base > image; it is therefore unlikely to have internal snapshots. In this > case, bdrv_make_empty() can be greatly sped up by emptying the L1 and > refcount table (while having the dirty flag set) and creating a trivial= > refcount structure. >=20 > If there are snapshots, fall back to the simple implementation (discard= > all clusters). >=20 > Signed-off-by: Max Reitz > --- > block/blkdebug.c | 2 + > block/qcow2.c | 137 ++++++++++++++++++++++++++++++++++++++++++= ++------ > include/block/block.h | 2 + > 3 files changed, 126 insertions(+), 15 deletions(-) >=20 > + } else { > + int l1_clusters; > + int64_t offset; > + uint64_t *new_reftable; > + uint8_t l1_ofs_rt_ofs_cls[20]; /* L1 offset; RT offset and clu= sters */ > + uint64_t rt_entry; > + > + ret =3D qcow2_cache_empty(bs, s->l2_table_cache); > if (ret < 0) { > - break; > + return ret; > + } > + > + ret =3D qcow2_cache_empty(bs, s->refcount_block_cache); > + if (ret < 0) { > + return ret; > + } > + > + /* Refcounts will be broken utterly */ > + ret =3D qcow2_mark_dirty(bs); qcow2_mark_dirty does assert(s->qcow_version >=3D 3). But this code can be reached when committing a qcow2 0.10 compat-level file, right? > + /* "Create" an empty reftable (one cluster) directly after the= image > + * header and an empty L1 table three clusters after the image= header; > + * the cluster between those two will be used as the first ref= block */ > + cpu_to_be64w((uint64_t *)&l1_ofs_rt_ofs_cls[ 0], 3 * s->cluste= r_size); > + cpu_to_be64w((uint64_t *)&l1_ofs_rt_ofs_cls[ 8], s->cluste= r_size); > + cpu_to_be32w((uint32_t *)&l1_ofs_rt_ofs_cls[16], 1); The offsets here feel a bit magic. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --gSRfJSnginnfdDfJaR7GQSBpcDKvJ1xaW 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUN9HjAAoJEKeha0olJ0Nqd6gH/082nuVK6boMUg12YDAG1v96 kmKBCchF5JDA4SBYwA5yJ6Bx+ozVvvo9UUyrpw7E592Sak7pCBC3FNP0wYQQps/a dEdI/LnzBdQT9F2+58SJD3evp/P/uBVv9laMT/8dDNcP5C7YIWru3smJB4uQq3qF ZThe93SYbxcn5nW28fSzrK4WW295UNo9WX4yRbwaGqaFTJfOLwbTtsnajKgOMggt c5pPcASG7/4avKA12BQG5zn/fVBbEMiWHAhunSVZEct2laBk1pXeb4lrnO2+1hc2 BSG01HX/shj41p/rMsLCXMZ6KzNHkwrEB9f9fIqo4HpzOSc/HpCOVUVOgJyxOic= =ZkYb -----END PGP SIGNATURE----- --gSRfJSnginnfdDfJaR7GQSBpcDKvJ1xaW--