From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tlp9S-0002BJ-QG for qemu-devel@nongnu.org; Thu, 20 Dec 2012 18:03:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tlp9Q-0004AU-KO for qemu-devel@nongnu.org; Thu, 20 Dec 2012 18:03:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63657) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tlp9Q-0004AP-Ce for qemu-devel@nongnu.org; Thu, 20 Dec 2012 18:03:40 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBKN3d8Z020492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Dec 2012 18:03:39 -0500 Message-ID: <50D3994A.6000801@redhat.com> Date: Thu, 20 Dec 2012 16:03:38 -0700 From: Eric Blake MIME-Version: 1.0 References: <1355319999-30627-1-git-send-email-pbonzini@redhat.com> <1355319999-30627-18-git-send-email-pbonzini@redhat.com> In-Reply-To: <1355319999-30627-18-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig751D0858A70A84E835EC8AA9" Subject: Re: [Qemu-devel] [PATCH 17/20] block: support a persistent dirty bitmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig751D0858A70A84E835EC8AA9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/12/2012 06:46 AM, Paolo Bonzini wrote: > Signed-off-by: Paolo Bonzini > --- > block.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++- > block.h | 5 +++ > block_int.h | 5 +++ > 3 files changed, 141 insertions(+), 2 deletions(-) >=20 > +void bdrv_enable_persistent_dirty_tracking(BlockDriverState *bs, const= char *file, > + Error **errp) > +{ > + int rc; > + int granularity_bits; > + int64_t bitmap_size; > + size_t file_size; > + QEMUMmapArea mm; > + HBitmap *new_bitmap; > + bool load; > + > + assert(bs->dirty_usage > 0); > + > + granularity_bits =3D hbitmap_granularity(bs->dirty_bitmap); > + bitmap_size =3D (bdrv_getlength(bs) >> BDRV_SECTOR_BITS); > + file_size =3D hbitmap_required_size(bitmap_size, granularity_bits)= ; > + > + load =3D access(file, R_OK) >=3D 0; > + if (bdrv_in_use(bs) && load) { > + error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));= > + return; > + } > + > + /* > + * Do not touch fields in BS until we're sure we can complete > + * successfully. > + */ > + rc =3D qemu_mmap_alloc(&mm, file, file_size); > + if (rc < 0) { > + error_set(errp, QERR_OPEN_FILE_FAILED, file); > + return; > + } > + > + new_bitmap =3D hbitmap_alloc_with_data(bitmap_size, granularity_bi= ts, mm.mem); > + if (!load) { > + hbitmap_copy(new_bitmap, bs->dirty_bitmap); Here's where my comment earlier in the series, about hbitmap_alloc_with_data repopulating the upper layers of the hbitmap on reused data, becomes essential. But since that fix is earlier in the series, and I didn't see anything else suspicious in this patch, you can add: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig751D0858A70A84E835EC8AA9 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.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBCAAGBQJQ05lKAAoJEKeha0olJ0NqguAH/0vuW+KqkMATC9VgpOcaQffd OhmfZOlTKL5BJZRWvb1UyuA4jWW1Ms7/NZMn9T0aZOUKkqVsVGK5XIEKzpJZa+LM 1mKIoR30nRtGPhfGYdmXUoBcwz3WVMPvzyfvNoEqfRpO9OCuVZdwBqEureGoA2cR JmpKV9pya6cBD8lSXbmt5FKbxTx5Klf4Js7T+Zx+dJFgWHMaXsS8Vw3YhGmjxcpi UgOGgTQ8vAi/kzh35MNQsAil6G3Zx7jfHBcOLzQDv/NVE6rACqF6LojZFZwtQkAE NIAq9xWuRrUwRPn8vw/LF/olUmbrLNtN4lirZwNR5yQodqd9XJ3zZ11u0H87PuA= =nUos -----END PGP SIGNATURE----- --------------enig751D0858A70A84E835EC8AA9--