crimson::ct_error::invarg,
crimson::ct_error::enospc
>;
- virtual allocate_ertr::future<> alloc_extent(Transaction &t, size_t size) = 0; // allocator, return blocks
+ using allocate_ret = allocate_ertr::future<paddr_t>;
+ // allocator, return start addr of allocated blocks
+ virtual allocate_ret alloc_extent(Transaction &t, size_t size) = 0;
using abort_allocation_ertr = crimson::errorator<
crimson::ct_error::input_output_error,
}
/* TODO : block allocator */
-NVMeManager::allocate_ertr::future<> NVMeManager::alloc_extent(
+NVMeManager::allocate_ret NVMeManager::alloc_extent(
Transaction &t, size_t size)
{
*
*/
return find_free_block(t, size
- ).safe_then([this] (auto alloc_extent) mutable
- -> allocate_ertr::future<> {
+ ).safe_then([this, &t] (auto alloc_extent) mutable
+ -> allocate_ertr::future<paddr_t> {
logger().debug("after find_free_block: allocated {}", alloc_extent);
if (!alloc_extent.empty()) {
rbm_alloc_delta_t alloc_info;
alloc_info.alloc_blk_ranges.push_back(std::make_pair(paddr, len));
alloc_info.op = rbm_alloc_delta_t::op_types_t::SET;
}
- // TODO: add alloc info to delta
+ t.add_rbm_alloc_info_blocks(alloc_info);
} else {
return crimson::ct_error::enospc::make();
}
- return allocate_ertr::now();
+ paddr_t paddr = convert_blk_paddr_to_paddr(
+ alloc_extent.range_start() * super.block_size,
+ super.block_size,
+ super.blocks_per_segment,
+ 0);
+ return allocate_ret(
+ allocate_ertr::ready_future_marker{},
+ paddr);
}
).handle_error(
allocate_ertr::pass_further{},