[metadata space map] Restrict space map size

Previously it would crash with v. large metadata areas.
This commit is contained in:
Joe Thornber 2015-06-24 16:32:17 +01:00
parent 125cec0193
commit c6844dc7e6
2 changed files with 6 additions and 0 deletions

View File

@ -747,6 +747,11 @@ persistent_data::create_metadata_sm(transaction_manager &tm, block_address nr_bl
{
index_store::ptr store(new metadata_index_store(tm));
checked_space_map::ptr sm(new sm_disk(store, tm));
if (nr_blocks > MAX_METADATA_BLOCKS) {
cerr << "truncating metadata device to " << MAX_METADATA_BLOCKS << " 4k blocks\n";
nr_blocks = MAX_METADATA_BLOCKS;
}
sm->extend(nr_blocks);
sm->commit();
return create_careful_alloc_sm(

View File

@ -61,6 +61,7 @@ namespace persistent_data {
};
unsigned const MAX_METADATA_BITMAPS = 255;
unsigned const MAX_METADATA_BLOCKS = (255 * ((1 << 14) - 64));
unsigned const ENTRIES_PER_BYTE = 4;
struct metadata_index {