BtreeLBAManager::alloc_extents_ret
BtreeLBAManager::alloc_extents(
Transaction &t,
- LBAMapping pos,
+ LBACursorRef cursor,
std::vector<LogicalChildNodeRef> extents)
{
LOG_PREFIX(BtreeLBAManager::alloc_extents);
- DEBUGT("{}", t, pos);
- assert(pos.is_viewable());
+ DEBUGT("{}", t, *cursor);
auto c = get_context(t);
auto btree = co_await get_btree<LBABtree>(cache, c);
- auto &cursor = pos.get_effective_cursor();
- co_await cursor.refresh();
- auto iter = btree.make_partial_iter(c, cursor);
- std::vector<LBAMapping> ret;
+ auto iter = btree.make_partial_iter(c, *cursor);
+ std::vector<LBACursorRef> ret;
for (auto eiter = extents.rbegin(); eiter != extents.rend(); ++eiter) {
auto ext = *eiter;
assert(ext->has_laddr());
ext.get(),
leaf_node.get_size() - 1 /*the size before the insert*/);
TRACET("inserted {}", c.trans, *ext);
- ret.emplace(ret.begin(), LBAMapping::create_direct(it.get_cursor(c)));
+ ret.emplace(ret.begin(), it.get_cursor(c));
iter = it;
#ifndef NDEBUG
if (eiter != extents.rend()) {
alloc_extents_ret alloc_extents(
Transaction &t,
- LBAMapping pos,
+ LBACursorRef pos,
std::vector<LogicalChildNodeRef> ext) final;
alloc_extent_ret alloc_extent(
cursors = co_await alloc_contiguous_mappings(
t, hint, alloc_infos, alloc_policy_t::linear_search);
}
- std::vector<LBAMapping> ret;
- for (auto &cursor : cursors) {
- ret.emplace_back(LBAMapping::create_direct(std::move(cursor)));
- }
- co_return ret;
+ co_return std::vector<LBACursorRef>(cursors.begin(), cursors.end());
}
base_iertr::future<LBACursorRef> update_mapping_refcount(
extent_ref_count_t refcount) = 0;
using alloc_extents_ret = alloc_extent_iertr::future<
- std::vector<LBAMapping>>;
+ std::vector<LBACursorRef>>;
virtual alloc_extents_ret alloc_extents(
Transaction &t,
laddr_t hint,
*/
virtual alloc_extents_ret alloc_extents(
Transaction &t,
- LBAMapping pos,
+ LBACursorRef cursor,
std::vector<LogicalChildNodeRef> ext) = 0;
struct clone_mapping_ret_t {
return *direct_cursor;
}
+ LBACursorRef get_effective_cursor_ref() {
+ if (is_indirect()) {
+ return indirect_cursor;
+ }
+ return direct_cursor;
+ }
+
bool is_null() const {
return !direct_cursor && !indirect_cursor;
}
auto npos = co_await pos->refresh();
co_await lba_manager->alloc_extents(
t,
- std::move(npos),
+ npos.get_effective_cursor_ref(),
std::vector<LogicalChildNodeRef>(
exts.begin(), exts.end()));
} else {
});
}).unsafe_get();
for (auto &ret : rets) {
- logger().debug("alloc'd: {}", ret);
- EXPECT_EQ(len, ret.get_length());
- auto [b, e] = get_overlap(t, ret.get_key(), len);
+ logger().debug("alloc'd: {}", *ret);
+ EXPECT_EQ(len, ret->get_length());
+ auto [b, e] = get_overlap(t, ret->get_laddr(), len);
EXPECT_EQ(b, e);
t.mappings.emplace(
std::make_pair(
- ret.get_key(),
+ ret->get_laddr(),
test_extent_t{
- ret.get_val(),
- ret.get_length(),
+ ret->get_paddr(),
+ ret->get_length(),
1
}
));