use sm transactional around sm disks

This commit is contained in:
Joe Thornber 2011-11-21 12:17:38 +00:00
parent 4df2123e9f
commit dc420bcc23
2 changed files with 26 additions and 3 deletions

View File

@ -5,6 +5,7 @@
#include "math_utils.h"
#include "space_map_disk_structures.h"
#include "space_map_recursive.h"
#include "space_map_transactional.h"
#include "transaction_manager.h"
using namespace boost;
@ -661,6 +662,7 @@ persistent_data::create_disk_sm(transaction_manager::ptr tm,
index_store::ptr store(new btree_index_store(tm));
checked_space_map::ptr sm(new sm_disk(store, tm));
sm->extend(nr_blocks);
sm->commit();
return sm;
}
@ -682,7 +684,9 @@ persistent_data::create_metadata_sm(transaction_manager::ptr tm, block_address n
index_store::ptr store(new metadata_index_store(tm));
checked_space_map::ptr sm(new sm_disk(store, tm));
sm->extend(nr_blocks);
return create_recursive_sm(sm);
sm->commit();
return create_transactional_sm(
create_recursive_sm(sm));
}
checked_space_map::ptr
@ -695,7 +699,9 @@ persistent_data::open_metadata_sm(transaction_manager::ptr tm, void *root)
sm_root_traits::unpack(d, v);
block_address nr_indexes = div_up<block_address>(v.nr_blocks_, ENTRIES_PER_BLOCK);
index_store::ptr store(new metadata_index_store(tm, v.bitmap_root_, nr_indexes));
return create_recursive_sm(checked_space_map::ptr(new sm_disk(store, tm, v)));
return create_transactional_sm(
create_recursive_sm(
checked_space_map::ptr(new sm_disk(store, tm, v))));
}
//----------------------------------------------------------------

View File

@ -55,7 +55,7 @@ namespace {
if (end <= search_start_)
return maybe_block();
maybe_block mb = sm_->new_block(max(search_start_, begin), end);
maybe_block mb = committed_->new_block(max(search_start_, begin), end);
if (mb) {
allocated_++;
search_start_ = *mb + 1;
@ -73,6 +73,10 @@ namespace {
return sm_->extend(extra_blocks);
}
virtual void iterate(iterator &it) const {
sm_->iterate(it);
}
virtual size_t root_size() const {
return sm_->root_size();
}
@ -81,6 +85,10 @@ namespace {
return sm_->copy_root(dest, len);
}
virtual void check(block_counter &counter) const {
return sm_->check(counter);
}
virtual checked_space_map::ptr clone() const {
return checked_space_map::ptr(new sm_transactional(sm_));
}
@ -93,4 +101,13 @@ namespace {
};
}
//----------------------------------------------------------------
checked_space_map::ptr
persistent_data::create_transactional_sm(checked_space_map::ptr sm)
{
return checked_space_map::ptr(new sm_transactional(sm));
}
//----------------------------------------------------------------