Transaction& t,
extent_types_t type,
segment_off_t length,
- placement_hint_t hint = placement_hint_t::NONE) {
+ placement_hint_t hint) {
// only logical extents should fall in this path
assert(is_logical_type(type));
assert(hint < placement_hint_t::NUM_HINTS);
auto dtype = get_allocator_type(hint);
- bool delay = can_delay_allocation(dtype);
+ // FIXME: set delay for COLD extent when the record overhead is low
+ bool delay = (hint > placement_hint_t::COLD &&
+ can_delay_allocation(dtype));
CachedExtentRef extent = cache.alloc_new_extent_by_type(
t, type, length, delay);
extent->backend_type = dtype;
TCachedExtentRef<T> alloc_new_extent(
Transaction& t,
segment_off_t length,
- placement_hint_t hint = placement_hint_t::NONE) {
+ placement_hint_t hint) {
// only logical extents should fall in this path
static_assert(is_logical_type(T::TYPE));
assert(hint < placement_hint_t::NUM_HINTS);
auto dtype = get_allocator_type(hint);
- bool delay = can_delay_allocation(dtype);
+ // FIXME: set delay for COLD extent when the record overhead is low
+ bool delay = (hint > placement_hint_t::COLD &&
+ can_delay_allocation(dtype));
TCachedExtentRef<T> extent = cache.alloc_new_extent<T>(
t, length, delay);
extent->backend_type = dtype;
LOG_PREFIX(ExtentPlacementManager::delayed_alloc_or_ool_write);
DEBUGT("start", t);
return seastar::do_with(
- std::map<ExtentAllocator*, std::list<LogicalCachedExtentRef>>(),
- std::list<std::pair<paddr_t, LogicalCachedExtentRef>>(),
- [this, &t](auto& alloc_map, auto& inline_list) mutable {
+ std::map<ExtentAllocator*, std::list<LogicalCachedExtentRef>>(),
+ [this, &t](auto& alloc_map) {
LOG_PREFIX(ExtentPlacementManager::delayed_alloc_or_ool_write);
auto& alloc_list = t.get_delayed_alloc_list();
uint64_t num_ool_extents = 0;
t.increment_delayed_invalid_extents();
continue;
}
- if (should_be_inline(extent)) {
- auto old_addr = extent->get_paddr();
- cache.mark_delayed_extent_inline(t, extent);
- inline_list.emplace_back(old_addr, extent);
- } else {
- auto& allocator_ptr = get_allocator(
- extent->backend_type, extent->hint
- );
- alloc_map[allocator_ptr.get()].emplace_back(extent);
- num_ool_extents++;
- }
+ // For now, just do ool allocation for any delayed extent
+ auto& allocator_ptr = get_allocator(
+ extent->backend_type, extent->hint
+ );
+ alloc_map[allocator_ptr.get()].emplace_back(extent);
+ num_ool_extents++;
}
- DEBUGT("{} inline extents, {} ool extents",
- t,
- inline_list.size(),
- num_ool_extents);
+ DEBUGT("{} ool extents", t, num_ool_extents);
return trans_intr::do_for_each(alloc_map, [&t](auto& p) {
auto allocator = p.first;
auto& extents = p.second;
return allocator->alloc_ool_extents_paddr(t, extents);
- }).si_then([&inline_list, this, &t] {
- LOG_PREFIX(ExtentPlacementManager::delayed_alloc_or_ool_write);
- DEBUGT("processing {} inline extents", t, inline_list.size());
- return trans_intr::do_for_each(inline_list, [this, &t](auto& p) {
- auto old_addr = p.first;
- auto& extent = p.second;
- return lba_manager.update_mapping(
- t,
- extent->get_laddr(),
- old_addr,
- extent->get_paddr());
- });
});
});
}
return device_type_t::SEGMENTED;
}
- bool should_be_inline(LogicalCachedExtentRef& extent) {
- return (std::rand() % 2) == 0;
- }
-
ExtentAllocatorRef& get_allocator(
device_type_t type,
placement_hint_t hint) {
* alloc_extent
*
* Allocates a new block of type T with the minimum lba range of size len
- * greater than hint.
+ * greater than laddr_hint.
*/
using alloc_extent_iertr = LBAManager::alloc_extent_iertr;
template <typename T>
template <typename T>
alloc_extent_ret<T> alloc_extent(
Transaction &t,
- laddr_t hint,
+ laddr_t laddr_hint,
extent_len_t len) {
+ placement_hint_t placement_hint;
+ if constexpr (T::TYPE == extent_types_t::OBJECT_DATA_BLOCK ||
+ T::TYPE == extent_types_t::COLL_BLOCK) {
+ placement_hint = placement_hint_t::COLD;
+ } else {
+ placement_hint = placement_hint_t::HOT;
+ }
auto ext = epm->alloc_new_extent<T>(
t,
- len);
+ len,
+ placement_hint);
return lba_manager->alloc_extent(
t,
- hint,
+ laddr_hint,
len,
ext->get_paddr()
- ).si_then([ext=std::move(ext), len, hint, &t, this](auto &&ref) mutable {
+ ).si_then([ext=std::move(ext), len, laddr_hint, &t, this](auto &&ref) mutable {
LOG_PREFIX(TransactionManager::alloc_extent);
ext->set_pin(std::move(ref));
stats.extents_allocated_total++;
stats.extents_allocated_bytes += len;
- DEBUGT("new extent: {}, hint: {}", t, *ext, hint);
+ DEBUGT("new extent: {}, laddr_hint: {}", t, *ext, laddr_hint);
return alloc_extent_iertr::make_ready_future<TCachedExtentRef<T>>(
std::move(ext));
});