max_size < range_size_alloc_threshold ||
free_pct < range_size_alloc_free_pct) {
*cursor = 0;
- start = _block_picker(range_size_tree, cursor, size, unit);
+ do {
+ start = _block_picker(range_size_tree, cursor, size, unit);
+ if (start != -1ULL || !force_range_size_alloc) {
+ break;
+ }
+ // try to collect smaller extents as we could fail to retrieve
+ // that large block due to misaligned extents
+ size = p2align(size >> 1, unit);
+ } while (size >= unit);
} else {
start = _block_picker(range_tree, cursor, size, unit);
}
alloc->shutdown();
}
+TEST_P(AllocTest, test_alloc_47883)
+{
+ uint64_t block = 0x1000;
+ uint64_t size = 1599858540544ul;
+
+ init_alloc(size, block);
+
+ alloc->init_add_free(0x1b970000, 0x26000);
+ alloc->init_add_free(0x1747e9d5000, 0x493000);
+ alloc->init_add_free(0x1747ee6a000, 0x196000);
+
+ PExtentVector extents;
+ auto need = 0x3f980000;
+ auto got = alloc->allocate(need, 0x10000, 0, (int64_t)0, &extents);
+ EXPECT_GT(got, 0);
+ EXPECT_EQ(got, 0x630000);
+}
+
INSTANTIATE_TEST_SUITE_P(
Allocator,
AllocTest,