Add metadata superblock and check it on start

Refuse to start if the superblock is missing or bad version;
zero out the metadata area when initializing superblock.
This commit is contained in:
Vitaliy Filippov
2021-04-10 22:26:17 +03:00
parent f684d9101a
commit 2a02f3c4c7
5 changed files with 152 additions and 27 deletions
+1 -1
View File
@@ -257,7 +257,7 @@ void blockstore_impl_t::calc_lengths()
}
// required metadata size
block_count = data_len / block_size;
meta_len = ((block_count - 1 + meta_block_size / clean_entry_size) / (meta_block_size / clean_entry_size)) * meta_block_size;
meta_len = (1 + (block_count - 1 + meta_block_size / clean_entry_size) / (meta_block_size / clean_entry_size)) * meta_block_size;
if (meta_area < meta_len)
{
throw std::runtime_error("Metadata area is too small, need at least "+std::to_string(meta_len)+" bytes");