virtual get_child_ret_t<lba_manager::btree::LBALeafNode, LogicalChildNode>
get_logical_extent(Transaction &t) = 0;
- void link_child(LogicalChildNode *c) {
- ceph_assert(child_pos);
- child_pos->link_child(c);
- }
virtual LBAMappingRef refresh_with_pending_parent() = 0;
// For reserved mappings, the return values are
extent_len_t len = 0;
fixed_kv_node_meta_t<laddr_t> range;
uint16_t pos = std::numeric_limits<uint16_t>::max();
-
- std::optional<child_pos_t<
- lba_manager::btree::LBALeafNode>> child_pos = std::nullopt;
};
std::ostream &operator<<(std::ostream &out, const LBAMapping &rhs);
return std::move(extent);
});
} else {
+ auto &r = std::get<0>(ret);
return this->pin_to_extent<T>(
- t, std::move(std::get<0>(ret)),
+ t, std::move(r.mapping), std::move(r.child_pos),
direct_partial_off, partial_len,
std::move(maybe_init));
}
shard_stats_t& shard_stats;
+ using LBALeafNode = lba_manager::btree::LBALeafNode;
+ struct unlinked_child_t {
+ LBAMappingRef mapping;
+ child_pos_t<LBALeafNode> child_pos;
+ };
template <typename T>
- std::variant<LBAMappingRef, get_child_ifut<T>>
+ std::variant<unlinked_child_t, get_child_ifut<T>>
get_extent_if_linked(
Transaction &t,
LBAMappingRef pin)
return extent->template cast<T>();
});
} else {
- return pin;
+ return unlinked_child_t{
+ std::move(pin),
+ v.get_child_pos()};
}
}
return ext;
});
} else {
- return pin_to_extent_by_type(t, std::move(pin), type);
+ return pin_to_extent_by_type(t, std::move(pin), v.get_child_pos(), type);
}
}
pin_to_extent_ret<T> pin_to_extent(
Transaction &t,
LBAMappingRef pin,
+ child_pos_t<LBALeafNode> child_pos,
extent_len_t direct_partial_off,
extent_len_t partial_len,
lextent_init_func_t<T> &&maybe_init) {
direct_length,
direct_partial_off,
partial_len,
- [&pref, maybe_init=std::move(maybe_init)]
+ [&pref, maybe_init=std::move(maybe_init),
+ child_pos=std::move(child_pos)]
(T &extent) mutable {
assert(extent.is_logical());
assert(!extent.has_laddr());
assert(!extent.has_been_invalidated());
assert(!pref.has_been_invalidated());
assert(pref.get_parent());
- pref.link_child(&extent);
+ child_pos.link_child(&extent);
extent.maybe_set_intermediate_laddr(pref);
maybe_init(extent);
extent.set_seen_by_users();
pin_to_extent_by_type_ret pin_to_extent_by_type(
Transaction &t,
LBAMappingRef pin,
+ child_pos_t<LBALeafNode> child_pos,
extent_types_t type)
{
LOG_PREFIX(TransactionManager::pin_to_extent_by_type);
pref.get_val(),
direct_key,
direct_length,
- [&pref](CachedExtent &extent) mutable {
+ [&pref, child_pos=std::move(child_pos)](CachedExtent &extent) mutable {
assert(extent.is_logical());
auto &lextent = static_cast<LogicalChildNode&>(extent);
assert(!lextent.has_laddr());
assert(!pref.has_been_invalidated());
assert(pref.get_parent());
assert(!pref.get_parent()->is_pending());
- pref.link_child(&lextent);
+ child_pos.link_child(&lextent);
lextent.maybe_set_intermediate_laddr(pref);
// No change to extent::seen_by_user because this path is only
// for background cleaning.