Fix metadata area size calculation, print free space, wait for free space

FIXME: Now it crashes with -ENOSPC on linear overwrite
This commit is contained in:
Vitaliy Filippov
2019-11-28 20:23:27 +03:00
parent 9fa0d3325f
commit b6fff5a77e
8 changed files with 38 additions and 11 deletions
+10 -1
View File
@@ -19,7 +19,7 @@ allocator::allocator(uint64_t blocks)
total -= p2;
total += (blocks+63) / 64;
mask = new uint64_t[2 + total];
size = blocks;
size = free = blocks;
last_one_mask = (blocks % 64) == 0
? UINT64_MAX
: ~(UINT64_MAX << (64 - blocks % 64));
@@ -55,6 +55,10 @@ void allocator::set(uint64_t addr, bool value)
uint64_t bit = cur_addr % 64;
if (((mask[last] >> bit) & 1) != value64)
{
if (is_last)
{
free += value ? -1 : 1;
}
if (value)
{
mask[last] = mask[last] | (1l << bit);
@@ -120,3 +124,8 @@ uint64_t allocator::find_free()
}
return addr;
}
uint64_t allocator::get_free_count()
{
return free;
}