Revert "hbitmap: Add @advance param to hbitmap_iter_next()"

This reverts commit a33fbb4f8b.

The functionality is unused.

Note: in addition to automatic revert, drop second parameter in
hbitmap_iter_next() call from hbitmap_next_dirty_area() too.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2019-01-15 18:26:50 -05:00 committed by John Snow
parent 4294c4ab48
commit 19c021e194
5 changed files with 20 additions and 27 deletions

View File

@ -385,7 +385,7 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
HBitmapIter hbi; HBitmapIter hbi;
hbitmap_iter_init(&hbi, job->copy_bitmap, 0); hbitmap_iter_init(&hbi, job->copy_bitmap, 0);
while ((cluster = hbitmap_iter_next(&hbi, true)) != -1) { while ((cluster = hbitmap_iter_next(&hbi)) != -1) {
do { do {
if (yield_and_check(job)) { if (yield_and_check(job)) {
return 0; return 0;

View File

@ -515,7 +515,7 @@ void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter)
int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter) int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter)
{ {
return hbitmap_iter_next(&iter->hbi, true); return hbitmap_iter_next(&iter->hbi);
} }
/* Called within bdrv_dirty_bitmap_lock..unlock */ /* Called within bdrv_dirty_bitmap_lock..unlock */

View File

@ -351,14 +351,11 @@ void hbitmap_free_meta(HBitmap *hb);
/** /**
* hbitmap_iter_next: * hbitmap_iter_next:
* @hbi: HBitmapIter to operate on. * @hbi: HBitmapIter to operate on.
* @advance: If true, advance the iterator. Otherwise, the next call
* of this function will return the same result (if that
* position is still dirty).
* *
* Return the next bit that is set in @hbi's associated HBitmap, * Return the next bit that is set in @hbi's associated HBitmap,
* or -1 if all remaining bits are zero. * or -1 if all remaining bits are zero.
*/ */
int64_t hbitmap_iter_next(HBitmapIter *hbi, bool advance); int64_t hbitmap_iter_next(HBitmapIter *hbi);
/** /**
* hbitmap_iter_next_word: * hbitmap_iter_next_word:

View File

@ -46,7 +46,7 @@ static void hbitmap_test_check(TestHBitmapData *data,
i = first; i = first;
for (;;) { for (;;) {
next = hbitmap_iter_next(&hbi, true); next = hbitmap_iter_next(&hbi);
if (next < 0) { if (next < 0) {
next = data->size; next = data->size;
} }
@ -435,25 +435,25 @@ static void test_hbitmap_iter_granularity(TestHBitmapData *data,
/* Note that hbitmap_test_check has to be invoked manually in this test. */ /* Note that hbitmap_test_check has to be invoked manually in this test. */
hbitmap_test_init(data, 131072 << 7, 7); hbitmap_test_init(data, 131072 << 7, 7);
hbitmap_iter_init(&hbi, data->hb, 0); hbitmap_iter_init(&hbi, data->hb, 0);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), <, 0); g_assert_cmpint(hbitmap_iter_next(&hbi), <, 0);
hbitmap_test_set(data, ((L2 + L1 + 1) << 7) + 8, 8); hbitmap_test_set(data, ((L2 + L1 + 1) << 7) + 8, 8);
hbitmap_iter_init(&hbi, data->hb, 0); hbitmap_iter_init(&hbi, data->hb, 0);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), ==, (L2 + L1 + 1) << 7); g_assert_cmpint(hbitmap_iter_next(&hbi), ==, (L2 + L1 + 1) << 7);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), <, 0); g_assert_cmpint(hbitmap_iter_next(&hbi), <, 0);
hbitmap_iter_init(&hbi, data->hb, (L2 + L1 + 2) << 7); hbitmap_iter_init(&hbi, data->hb, (L2 + L1 + 2) << 7);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), <, 0); g_assert_cmpint(hbitmap_iter_next(&hbi), <, 0);
hbitmap_test_set(data, (131072 << 7) - 8, 8); hbitmap_test_set(data, (131072 << 7) - 8, 8);
hbitmap_iter_init(&hbi, data->hb, 0); hbitmap_iter_init(&hbi, data->hb, 0);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), ==, (L2 + L1 + 1) << 7); g_assert_cmpint(hbitmap_iter_next(&hbi), ==, (L2 + L1 + 1) << 7);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), ==, 131071 << 7); g_assert_cmpint(hbitmap_iter_next(&hbi), ==, 131071 << 7);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), <, 0); g_assert_cmpint(hbitmap_iter_next(&hbi), <, 0);
hbitmap_iter_init(&hbi, data->hb, (L2 + L1 + 2) << 7); hbitmap_iter_init(&hbi, data->hb, (L2 + L1 + 2) << 7);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), ==, 131071 << 7); g_assert_cmpint(hbitmap_iter_next(&hbi), ==, 131071 << 7);
g_assert_cmpint(hbitmap_iter_next(&hbi, true), <, 0); g_assert_cmpint(hbitmap_iter_next(&hbi), <, 0);
} }
static void hbitmap_test_set_boundary_bits(TestHBitmapData *data, ssize_t diff) static void hbitmap_test_set_boundary_bits(TestHBitmapData *data, ssize_t diff)
@ -893,7 +893,7 @@ static void test_hbitmap_serialize_zeroes(TestHBitmapData *data,
for (i = 0; i < num_positions; i++) { for (i = 0; i < num_positions; i++) {
hbitmap_deserialize_zeroes(data->hb, positions[i], min_l1, true); hbitmap_deserialize_zeroes(data->hb, positions[i], min_l1, true);
hbitmap_iter_init(&iter, data->hb, 0); hbitmap_iter_init(&iter, data->hb, 0);
next = hbitmap_iter_next(&iter, true); next = hbitmap_iter_next(&iter);
if (i == num_positions - 1) { if (i == num_positions - 1) {
g_assert_cmpint(next, ==, -1); g_assert_cmpint(next, ==, -1);
} else { } else {
@ -919,10 +919,10 @@ static void test_hbitmap_iter_and_reset(TestHBitmapData *data,
hbitmap_iter_init(&hbi, data->hb, BITS_PER_LONG - 1); hbitmap_iter_init(&hbi, data->hb, BITS_PER_LONG - 1);
hbitmap_iter_next(&hbi, true); hbitmap_iter_next(&hbi);
hbitmap_reset_all(data->hb); hbitmap_reset_all(data->hb);
hbitmap_iter_next(&hbi, true); hbitmap_iter_next(&hbi);
} }
static void test_hbitmap_next_zero_check_range(TestHBitmapData *data, static void test_hbitmap_next_zero_check_range(TestHBitmapData *data,

View File

@ -144,7 +144,7 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi)
return cur; return cur;
} }
int64_t hbitmap_iter_next(HBitmapIter *hbi, bool advance) int64_t hbitmap_iter_next(HBitmapIter *hbi)
{ {
unsigned long cur = hbi->cur[HBITMAP_LEVELS - 1] & unsigned long cur = hbi->cur[HBITMAP_LEVELS - 1] &
hbi->hb->levels[HBITMAP_LEVELS - 1][hbi->pos]; hbi->hb->levels[HBITMAP_LEVELS - 1][hbi->pos];
@ -157,12 +157,8 @@ int64_t hbitmap_iter_next(HBitmapIter *hbi, bool advance)
} }
} }
if (advance) { /* The next call will resume work from the next bit. */
/* The next call will resume work from the next bit. */ hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1);
hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1);
} else {
hbi->cur[HBITMAP_LEVELS - 1] = cur;
}
item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur); item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur);
return item << hbi->granularity; return item << hbi->granularity;
@ -261,7 +257,7 @@ bool hbitmap_next_dirty_area(const HBitmap *hb, uint64_t *start,
end = *count > hb->orig_size - *start ? hb->orig_size : *start + *count; end = *count > hb->orig_size - *start ? hb->orig_size : *start + *count;
hbitmap_iter_init(&hbi, hb, *start); hbitmap_iter_init(&hbi, hb, *start);
firt_dirty_off = hbitmap_iter_next(&hbi, false); firt_dirty_off = hbitmap_iter_next(&hbi);
if (firt_dirty_off < 0 || firt_dirty_off >= end) { if (firt_dirty_off < 0 || firt_dirty_off >= end) {
return false; return false;