On 18.07.2016 22:57, John Snow wrote: > From: Fam Zheng <[email protected]> > > The added group of operations enables tracking of the changed bits in > the dirty bitmap. > > Signed-off-by: Fam Zheng <[email protected]> > Reviewed-by: Max Reitz <[email protected]> > Signed-off-by: John Snow <[email protected]> > --- > block/dirty-bitmap.c | 52 > ++++++++++++++++++++++++++++++++++++++++++++ > include/block/dirty-bitmap.h | 9 ++++++++ > 2 files changed, 61 insertions(+)
[...]
> +int bdrv_dirty_bitmap_get_meta(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap, int64_t sector,
> + int nb_sectors)
> +{
> + uint64_t i;
> + int gran = hbitmap_granularity(bitmap->meta);
/me is making a note first: If John says an optimization may be
premature, it probably is.
Did I say hbitmap_granularity()? I may have wanted to actually say
"1 << hbitmap_granularity()". Sorry. :-/
/me is making a second note now: Look up how something works before
proposing it, not after someone has actually followed your advice.
Max
> +
> + /* To optimize: we can make hbitmap to internally check the range in a
> + * coarse level, or at least do it word by word. */
> + for (i = sector; i < sector + nb_sectors; i += gran) {
> + if (hbitmap_get(bitmap->meta, i)) {
> + return true;
> + }
> + }
> + return false;
> +}
signature.asc
Description: OpenPGP digital signature
