From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7o4z-0004oE-NO for qemu-devel@nongnu.org; Wed, 03 Oct 2018 16:49:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7o4q-0002SP-6I for qemu-devel@nongnu.org; Wed, 03 Oct 2018 16:49:05 -0400 References: <20181002233314.30159-1-jsnow@redhat.com> From: John Snow Message-ID: <2ef8c12c-9044-4ea4-c5ec-69a6e98d9f69@redhat.com> Date: Wed, 3 Oct 2018 16:48:37 -0400 MIME-Version: 1.0 In-Reply-To: <20181002233314.30159-1-jsnow@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] bitmap: Update count after a merge List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-stable@nongnu.org Cc: vsementsov@virtuozzo.com, Fam Zheng , qemu-block@nongnu.org, qemu-devel@nongnu.org On 10/02/2018 07:33 PM, John Snow wrote: > From: Eric Blake > > We need an accurate count of the number of bits set in a bitmap > after a merge. In particular, since the merge operation short-circuits > a merge from an empty source, if you have bitmaps A, B, and C where > B started empty, then merge C into B, and B into A, an inaccurate > count meant that A did not get the contents of C. > > In the worst case, we may falsely regard the bitmap as empty when > it has had new writes merged into it. > > Fixes: be58721db > CC: qemu-stable@nongnu.org > Signed-off-by: Eric Blake > Signed-off-by: John Snow > --- > > v2: based off of Eric's cover letter, now rebased properly > on top of the jsnow/bitmaps staging branch to use the > correct bitmap target (result). > > > util/hbitmap.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/util/hbitmap.c b/util/hbitmap.c > index d5aca5159f..8d402c59d9 100644 > --- a/util/hbitmap.c > +++ b/util/hbitmap.c > @@ -759,6 +759,9 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result) > } > } > > + /* Recompute the dirty count */ > + result->count = hb_count_between(result, 0, result->size - 1); > + > return true; > } > > Tests on the way, but for now... Thanks, applied to my bitmaps tree: https://github.com/jnsnow/qemu/commits/bitmaps https://github.com/jnsnow/qemu.git --js