Use a separate used_blocks counter for free space stats to hide possibly delayed on-flush deallocation

kv-update
Vitaliy Filippov 2023-12-29 23:35:34 +03:00
parent d5a6fa6dd7
commit 8b8c1179a7
3 changed files with 6 additions and 1 deletions

View File

@ -277,6 +277,7 @@ class blockstore_impl_t
int unsynced_big_write_count = 0, unstable_unsynced = 0;
int unsynced_queued_ops = 0;
allocator *data_alloc = NULL;
uint64_t used_blocks = 0;
uint8_t *zero_object;
void *metadata_buffer = NULL;
@ -430,7 +431,7 @@ public:
inline uint32_t get_block_size() { return dsk.data_block_size; }
inline uint64_t get_block_count() { return dsk.block_count; }
inline uint64_t get_free_block_count() { return data_alloc->get_free_count(); }
inline uint64_t get_free_block_count() { return dsk.block_count - used_blocks; }
inline uint32_t get_bitmap_granularity() { return dsk.disk_alignment; }
inline uint64_t get_journal_size() { return dsk.journal_len; }
};

View File

@ -376,6 +376,7 @@ bool blockstore_init_meta::handle_meta_block(uint8_t *buf, uint64_t entries_per_
else
{
bs->inode_space_stats[entry->oid.inode] += bs->dsk.data_block_size;
bs->used_blocks++;
}
entries_loaded++;
#ifdef BLOCKSTORE_DEBUG
@ -1181,6 +1182,7 @@ void blockstore_init_journal::erase_dirty_object(blockstore_dirty_db_t::iterator
sp -= bs->dsk.data_block_size;
else
bs->inode_space_stats.erase(oid.inode);
bs->used_blocks--;
}
bs->erase_dirty(dirty_it, dirty_end, clean_loc);
// Remove it from the flusher's queue, too

View File

@ -445,6 +445,7 @@ void blockstore_impl_t::mark_stable(const obj_ver_id & v, bool forget_dirty)
if (!exists)
{
inode_space_stats[dirty_it->first.oid.inode] += dsk.data_block_size;
used_blocks++;
}
big_to_flush++;
}
@ -455,6 +456,7 @@ void blockstore_impl_t::mark_stable(const obj_ver_id & v, bool forget_dirty)
sp -= dsk.data_block_size;
else
inode_space_stats.erase(dirty_it->first.oid.inode);
used_blocks--;
big_to_flush++;
}
}