* time.
*/
template <typename key_t, typename val_t>
-struct BtreeCursor {
+struct BtreeCursor
+ : public boost::intrusive_ref_counter<
+ BtreeCursor<key_t, val_t>, boost::thread_unsafe_counter> {
BtreeCursor(
op_context_t &ctx,
CachedExtentRef parent,
assert(!is_indirect());
return val->refcount;
}
-
std::unique_ptr<LBACursor> duplicate() const {
return std::make_unique<LBACursor>(*this);
}
using base_iertr = trans_iertr<base_ertr>;
base_iertr::future<> refresh();
};
-using LBACursorRef = std::unique_ptr<LBACursor>;
+using LBACursorRef = boost::intrusive_ptr<LBACursor>;
struct BackrefCursor : BtreeCursor<paddr_t, backref::backref_map_val_t> {
using Base = BtreeCursor<paddr_t, backref::backref_map_val_t>;
return val->type;
}
};
-using BackrefCursorRef = std::unique_ptr<BackrefCursor>;
+using BackrefCursorRef = boost::intrusive_ptr<BackrefCursor>;
template <typename key_t, typename val_t>
std::ostream &operator<<(
}
// handle_boundary() must be called before get_cursor
- std::unique_ptr<cursor_t> get_cursor(op_context_t ctx) const {
- assert(!is_end());
- return std::make_unique<cursor_t>(
+ boost::intrusive_ptr<cursor_t> get_cursor(op_context_t ctx) const {
+ return new cursor_t(
ctx,
leaf.node,
leaf.node->modifications,
cursor.pos);
}
- std::unique_ptr<cursor_t> get_cursor(
+ boost::intrusive_ptr<cursor_t> get_cursor(
op_context_t c,
TCachedExtentRef<leaf_node_t> leaf,
node_key_t key)
assert(leaf->get_size() != pos);
auto it = leaf->iter_idx(pos);
assert(it.get_key() == key);
- return std::make_unique<cursor_t>(
- c, leaf, leaf->modifications, key, it.get_val(), pos);
+ return new cursor_t(c, leaf, leaf->modifications, key, it.get_val(), pos);
}
/**
using lba::LBALeafNode;
get_child_ret_t<LBALeafNode, LogicalChildNode>
-LBAMapping::get_logical_extent(Transaction &t)
+LBAMapping::get_logical_extent(Transaction &t) const
{
assert(is_linked_direct());
ceph_assert(direct_cursor->is_viewable());
}
LBAMapping() = delete;
- LBAMapping(const LBAMapping &) = delete;
+ LBAMapping(const LBAMapping &) = default;
LBAMapping(LBAMapping &&) = default;
- LBAMapping &operator=(const LBAMapping &) = delete;
+ LBAMapping &operator=(const LBAMapping &) = default;
LBAMapping &operator=(LBAMapping &&) = default;
~LBAMapping() = default;
}
get_child_ret_t<lba::LBALeafNode, LogicalChildNode>
- get_logical_extent(Transaction &t);
+ get_logical_extent(Transaction &t) const;
LBAMapping duplicate() const {
+ assert(!is_null());
auto dup_iter = [](const LBACursorRef &iter) -> LBACursorRef {
if (iter) {
return iter->duplicate();
return mapping.refresh().si_then([&t, this, FNAME](auto mapping) {
auto fut = base_iertr::make_ready_future<LogicalChildNodeRef>();
if (!mapping.is_indirect() && mapping.get_val().is_real_location()) {
- auto ret = get_extent_if_linked<LogicalChildNode>(t, mapping.duplicate());
+ auto ret = get_extent_if_linked<LogicalChildNode>(t, mapping);
if (ret.index() == 1) {
fut = std::move(std::get<1>(ret));
}
auto v = pin.get_logical_extent(t);
if (v.has_child()) {
return v.get_child_fut(
- ).si_then([pin=std::move(pin)](auto extent) {
+ ).si_then([pin=pin.duplicate()](auto extent) {
#ifndef NDEBUG
auto lextent = extent->template cast<LogicalChildNode>();
auto pin_laddr = pin.get_intermediate_base();
});
} else {
return unlinked_child_t{
- std::move(pin),
+ std::move(const_cast<LBAMapping&>(pin)),
v.get_child_pos()};
}
}
return ext;
});
} else {
- return pin_to_extent_by_type(t, std::move(pin), v.get_child_pos(), type);
+ return pin_to_extent_by_type(t, pin.duplicate(), v.get_child_pos(), type);
}
}
static_assert(is_logical_type(T::TYPE));
// must be user-oriented required by maybe_init
assert(is_user_transaction(t.get_src()));
+ assert(pin.is_viewable());
using ret = pin_to_extent_ret<T>;
auto direct_length = pin.get_intermediate_length();
if (full_extent_integrity_check) {
maybe_init(extent);
extent.set_seen_by_users();
}
- ).si_then([FNAME, &t, pin=std::move(pin), this](auto ref) mutable -> ret {
+ ).si_then([FNAME, &t, pin=pin.duplicate(), this](auto ref) mutable -> ret {
if (ref->is_fully_loaded()) {
auto crc = ref->calc_crc32c();
SUBTRACET(
LOG_PREFIX(TransactionManager::pin_to_extent_by_type);
SUBTRACET(seastore_tm, "getting absent extent from pin {} type {} ...",
t, pin, type);
+ assert(pin.is_viewable());
assert(is_logical_type(type));
assert(is_background_transaction(t.get_src()));
laddr_t direct_key = pin.get_intermediate_base();
// No change to extent::seen_by_user because this path is only
// for background cleaning.
}
- ).si_then([FNAME, &t, pin=std::move(pin), this](auto ref) {
+ ).si_then([FNAME, &t, pin=pin.duplicate(), this](auto ref) {
auto crc = ref->calc_crc32c();
SUBTRACET(
seastore_tm,
TestBlockRef try_read_pin(
test_transaction_t &t,
- LBAMapping &&pin) {
+ const LBAMapping pin) {
using ertr = with_trans_ertr<TransactionManager::base_iertr>;
bool indirect = pin.is_indirect();
auto addr = pin.get_key();
auto im_addr = pin.get_intermediate_base();
auto ext = with_trans_intr(*(t.t), [&](auto& trans) {
- return tm->read_pin<TestBlock>(trans, std::move(pin));
+ return tm->read_pin<TestBlock>(trans, pin.duplicate());
}).safe_then([](auto ret) {
return ertr::make_ready_future<TestBlockRef>(ret.extent);
}).handle_error(
}
auto t = create_transaction();
- auto pin0 = try_get_pin(t, offset);
- if (!pin0 || pin0->get_length() != length) {
+ auto last_pin = try_get_pin(t, offset);
+ if (!last_pin || last_pin->get_length() != length) {
early_exit++;
return;
}
- auto last_pin = pin0->duplicate();
ASSERT_TRUE(!split_points.empty());
for (auto off : split_points) {
if (off == 0 || off >= 255) {
conflicted++;
return;
}
- last_pin = pin->duplicate();
+ last_pin = std::move(pin);
}
auto last_ext = try_get_extent(t, last_pin.get_key());
if (!last_ext) {
}
}
ASSERT_TRUE(rpin);
- last_rpin = rpin->duplicate();
+ last_rpin = std::move(*rpin);
}
auto last_rext = try_get_extent(t, last_rpin.get_key());
if (!last_rext) {