[everything] Fix circular shared pointer references.
We had a cycle from transaction_manager <-> space_map, and also from the ref_counters back up to the tm. This prevented objects being destroyed when various programs exited. From now on we'll try and only use a shared ptr if ownership is implied. Otherwise a reference will be used (eg, for up pointers).
This commit is contained in:
@@ -237,7 +237,7 @@ namespace {
|
||||
out << "examining mapping array" << end_message();
|
||||
{
|
||||
nested_output::nest _ = out.push();
|
||||
mapping_array ma(tm, mapping_array::ref_counter(), sb.mapping_root, sb.cache_blocks);
|
||||
mapping_array ma(*tm, mapping_array::ref_counter(), sb.mapping_root, sb.cache_blocks);
|
||||
check_mapping_array(ma, mapping_rep);
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ namespace {
|
||||
out << "examining hint array" << end_message();
|
||||
{
|
||||
nested_output::nest _ = out.push();
|
||||
hint_array ha(tm, sb.policy_hint_size, sb.hint_root, sb.cache_blocks);
|
||||
hint_array ha(*tm, sb.policy_hint_size, sb.hint_root, sb.cache_blocks);
|
||||
ha.check(hint_rep);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ namespace {
|
||||
out << "examining discard bitset" << end_message();
|
||||
{
|
||||
nested_output::nest _ = out.push();
|
||||
persistent_data::bitset discards(tm, sb.discard_root, sb.discard_nr_blocks);
|
||||
persistent_data::bitset discards(*tm, sb.discard_root, sb.discard_nr_blocks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ namespace {
|
||||
xx(4);
|
||||
|
||||
template <uint32_t WIDTH>
|
||||
shared_ptr<array_base> mk_array(transaction_manager::ptr tm) {
|
||||
shared_ptr<array_base> mk_array(transaction_manager &tm) {
|
||||
typedef hint_traits<WIDTH> traits;
|
||||
typedef array<traits> ha;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace {
|
||||
return r;
|
||||
}
|
||||
|
||||
shared_ptr<array_base> mk_array(transaction_manager::ptr tm, uint32_t width) {
|
||||
shared_ptr<array_base> mk_array(transaction_manager &tm, uint32_t width) {
|
||||
switch (width) {
|
||||
#define xx(n) case n: return mk_array<n>(tm)
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace {
|
||||
//--------------------------------
|
||||
|
||||
template <uint32_t WIDTH>
|
||||
shared_ptr<array_base> mk_array(transaction_manager::ptr tm, block_address root, unsigned nr_entries) {
|
||||
shared_ptr<array_base> mk_array(transaction_manager &tm, block_address root, unsigned nr_entries) {
|
||||
typedef hint_traits<WIDTH> traits;
|
||||
typedef array<traits> ha;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace {
|
||||
return r;
|
||||
}
|
||||
|
||||
shared_ptr<array_base> mk_array(transaction_manager::ptr tm, uint32_t width, block_address root, unsigned nr_entries) {
|
||||
shared_ptr<array_base> mk_array(transaction_manager &tm, uint32_t width, block_address root, unsigned nr_entries) {
|
||||
switch (width) {
|
||||
#define xx(n) case n: return mk_array<n>(tm, root, nr_entries)
|
||||
all_widths
|
||||
@@ -230,13 +230,13 @@ missing_hints::visit(damage_visitor &v) const
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
hint_array::hint_array(tm_ptr tm, unsigned width)
|
||||
hint_array::hint_array(transaction_manager &tm, unsigned width)
|
||||
: width_(check_width(width)),
|
||||
impl_(mk_array(tm, width))
|
||||
{
|
||||
}
|
||||
|
||||
hint_array::hint_array(hint_array::tm_ptr tm, unsigned width,
|
||||
hint_array::hint_array(transaction_manager &tm, unsigned width,
|
||||
block_address root, unsigned nr_entries)
|
||||
: width_(check_width(width)),
|
||||
impl_(mk_array(tm, width, root, nr_entries))
|
||||
|
@@ -56,10 +56,9 @@ namespace caching {
|
||||
class hint_array {
|
||||
public:
|
||||
typedef boost::shared_ptr<hint_array> ptr;
|
||||
typedef persistent_data::transaction_manager::ptr tm_ptr;
|
||||
|
||||
hint_array(tm_ptr tm, unsigned width);
|
||||
hint_array(tm_ptr tm, unsigned width, block_address root, unsigned nr_entries);
|
||||
hint_array(transaction_manager &tm, unsigned width);
|
||||
hint_array(transaction_manager &tm, unsigned width, block_address root, unsigned nr_entries);
|
||||
|
||||
unsigned get_nr_entries() const;
|
||||
|
||||
|
@@ -61,7 +61,7 @@ metadata::setup_hint_array(size_t width)
|
||||
{
|
||||
if (width > 0)
|
||||
hints_ = hint_array::ptr(
|
||||
new hint_array(tm_, width));
|
||||
new hint_array(*tm_, width));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -70,16 +70,16 @@ metadata::create_metadata(block_manager<>::ptr bm)
|
||||
tm_ = open_tm(bm);
|
||||
|
||||
space_map::ptr core = tm_->get_sm();
|
||||
metadata_sm_ = create_metadata_sm(tm_, tm_->get_bm()->get_nr_blocks());
|
||||
metadata_sm_ = create_metadata_sm(*tm_, tm_->get_bm()->get_nr_blocks());
|
||||
copy_space_maps(metadata_sm_, core);
|
||||
tm_->set_sm(metadata_sm_);
|
||||
|
||||
mappings_ = mapping_array::ptr(new mapping_array(tm_, mapping_array::ref_counter()));
|
||||
mappings_ = mapping_array::ptr(new mapping_array(*tm_, mapping_array::ref_counter()));
|
||||
|
||||
// We can't instantiate the hint array yet, since we don't know the
|
||||
// hint width.
|
||||
|
||||
discard_bits_ = persistent_data::bitset::ptr(new persistent_data::bitset(tm_));
|
||||
discard_bits_ = persistent_data::bitset::ptr(new persistent_data::bitset(*tm_));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -89,19 +89,19 @@ metadata::open_metadata(block_manager<>::ptr bm)
|
||||
sb_ = read_superblock(tm_->get_bm());
|
||||
|
||||
mappings_ = mapping_array::ptr(
|
||||
new mapping_array(tm_,
|
||||
new mapping_array(*tm_,
|
||||
mapping_array::ref_counter(),
|
||||
sb_.mapping_root,
|
||||
sb_.cache_blocks));
|
||||
|
||||
if (sb_.hint_root)
|
||||
hints_ = hint_array::ptr(
|
||||
new hint_array(tm_, sb_.policy_hint_size,
|
||||
new hint_array(*tm_, sb_.policy_hint_size,
|
||||
sb_.hint_root, sb_.cache_blocks));
|
||||
|
||||
if (sb_.discard_root)
|
||||
discard_bits_ = persistent_data::bitset::ptr(
|
||||
new persistent_data::bitset(tm_, sb_.discard_root, sb_.discard_nr_blocks));
|
||||
new persistent_data::bitset(*tm_, sb_.discard_root, sb_.discard_nr_blocks));
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user