Received: from eggs.gnu.org ([2001:4830:134:3::10]:57162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPBL0-0006yq-O6 for qemu-devel@nongnu.org; Mon, 18 Jul 2016 12:24:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPBKy-0001v1-I3 for qemu-devel@nongnu.org; Mon, 18 Jul 2016 12:24:09 -0400 References: <1468614461-28807-1-git-send-email-jsnow@redhat.com> <1468614461-28807-5-git-send-email-jsnow@redhat.com> <2a65d1cd-1b1d-7a40-9404-7cbeee1240da@redhat.com> From: John Snow Message-ID: Date: Mon, 18 Jul 2016 12:24:01 -0400 MIME-Version: 1.0 In-Reply-To: <2a65d1cd-1b1d-7a40-9404-7cbeee1240da@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 04/10] block: Support meta dirty bitmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, famz@redhat.com, qemu-devel@nongnu.org On 07/18/2016 10:57 AM, Max Reitz wrote: > On 15.07.2016 22:27, John Snow wrote: >> From: Fam Zheng >> >> The added group of operations enables tracking of the changed bits in >> the dirty bitmap. >> >> Signed-off-by: Fam Zheng >> Reviewed-by: Max Reitz >> Signed-off-by: John Snow >> --- >> block/dirty-bitmap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ >> include/block/dirty-bitmap.h | 9 ++++++++ >> 2 files changed, 61 insertions(+) >> >> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c >> index 628b77c..9c53c56 100644 >> --- a/block/dirty-bitmap.c >> +++ b/block/dirty-bitmap.c >> @@ -38,6 +38,7 @@ > > [...] > >> +int bdrv_dirty_bitmap_get_meta(BlockDriverState *bs, >> + BdrvDirtyBitmap *bitmap, int64_t sector, >> + int nb_sectors) >> +{ >> + uint64_t i; >> + int gran = bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS; >> + >> + /* To optimize: we can make hbitmap to internally check the range in a >> + * coarse level, or at least do it word by word. */ > > So you really want to leave even the simple optimizations for later? :-) > I guess partly I felt bad about not going all the way on it, but I can bring it a little closer :) > (i.e. "int gran = hbitmap_granularity(bitmap->meta);") > > Max > >> + for (i = sector; i < sector + nb_sectors; i += gran) { >> + if (hbitmap_get(bitmap->meta, i)) { >> + return true; >> + } >> + } >> + return false; >> +} > >