Received: from eggs.gnu.org ([2001:4830:134:3::10]:42388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWm7T-000701-FR for qemu-devel@nongnu.org; Mon, 08 Aug 2016 11:05:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWm7P-0004Rb-Tu for qemu-devel@nongnu.org; Mon, 08 Aug 2016 11:05:35 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:5336 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWm7P-0004QE-Gd for qemu-devel@nongnu.org; Mon, 08 Aug 2016 11:05:31 -0400 From: Vladimir Sementsov-Ogievskiy Date: Mon, 8 Aug 2016 18:04:52 +0300 Message-Id: <1470668720-211300-2-git-send-email-vsementsov@virtuozzo.com> In-Reply-To: <1470668720-211300-1-git-send-email-vsementsov@virtuozzo.com> References: <1470668720-211300-1-git-send-email-vsementsov@virtuozzo.com> Subject: [Qemu-devel] [PATCH 01/29] hbitmap: fix dirty iter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, armbru@redhat.com, eblake@redhat.com, jsnow@redhat.com, famz@redhat.com, den@openvz.org, stefanha@redhat.com, vsementsov@virtuozzo.com, pbonzini@redhat.com If dirty bitmap was cleared during iterator life, we can went to zero current in hbitmap_iter_skip_words, starting from saved (and currently wrong hbi->cur[...]). Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Denis V. Lunev --- util/hbitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/hbitmap.c b/util/hbitmap.c index 6a13c12..f807f64 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -106,8 +106,9 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi) unsigned long cur; do { - cur = hbi->cur[--i]; + i--; pos >>= BITS_PER_LEVEL; + cur = hbi->cur[i] & hb->levels[i][pos]; } while (cur == 0); /* Check for end of iteration. We always use fewer than BITS_PER_LONG -- 1.8.3.1