}
void add_to_retired_set(CachedExtentRef ref) {
+ ceph_assert(!is_weak());
if (!ref->is_initial_pending()) {
// && retired_set.count(ref->get_paddr()) == 0
// If it's already in the set, insert here will be a noop,
}
void add_to_read_set(CachedExtentRef ref) {
+ if (is_weak()) return;
+
ceph_assert(read_set.count(ref) == 0);
read_set.insert(ref);
}
void add_fresh_extent(CachedExtentRef ref) {
+ ceph_assert(!is_weak());
fresh_block_list.push_back(ref);
ref->set_paddr(make_record_relative_paddr(offset));
offset += ref->get_length();
}
void add_mutated_extent(CachedExtentRef ref) {
+ ceph_assert(!is_weak());
mutated_block_list.push_back(ref);
write_set.insert(*ref);
}
return retired_set;
}
+ bool is_weak() const {
+ return weak;
+ }
+
private:
friend class Cache;
+ friend Ref make_transaction();
+ friend Ref make_weak_transaction();
+
+ /**
+ * If set, *this may not be used to perform writes and will not provide
+ * consistentency allowing operations using to avoid maintaining a read_set.
+ */
+ const bool weak;
RootBlockRef root; ///< ref to root if read or written by transaction
std::list<CachedExtentRef> mutated_block_list; ///< list of mutated blocks
pextent_set_t retired_set; ///< list of extents mutated by this transaction
+
+ Transaction(bool weak) : weak(weak) {}
};
using TransactionRef = Transaction::Ref;
inline TransactionRef make_transaction() {
- return std::make_unique<Transaction>();
+ return std::unique_ptr<Transaction>(new Transaction(false));
+}
+
+inline TransactionRef make_weak_transaction() {
+ return std::unique_ptr<Transaction>(new Transaction(true));
}
}
return { tm->create_transaction(), test_mappings };
}
+ test_transaction_t create_weak_transaction() {
+ return { tm->create_weak_transaction(), test_mappings };
+ }
+
TestBlockRef alloc_extent(
test_transaction_t &t,
laddr_t hint,
}
void check_mappings() {
- auto t = create_transaction();
+ auto t = create_weak_transaction();
check_mappings(t);
}
auto ext = get_extent(t, i.first, i.second.desc.len);
EXPECT_EQ(i.second, ext->get_desc());
}
- auto lt = create_lazy_transaction();
+ auto lt = create_weak_transaction();
lba_manager->scan_mappings(
*lt.t,
0,