03.10.2018 02:33, John Snow wrote: > From: Eric Blake <[email protected]> > > 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: [email protected] > Signed-off-by: Eric Blake <[email protected]> > Signed-off-by: John Snow <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]> Hm, I rememberd: commit 3260cdfffbf00f33923f5f9f6bef45932d7ac28b Author: Liang Li <[email protected]> Date: Wed Feb 7 11:35:49 2018 -0500 hbitmap: fix missing restore count when finish deserialization The .count of HBitmap is forgot to set in function hbitmap_deserialize_finish, let's set it to the right value. - I always forget to update this field.. We definitely should add some generic check on it somewhere, at least in tests. > --- > > 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; > } > -- Best regards, Vladimir
