assert(is_logical_type(type));
assert(hint < placement_hint_t::NUM_HINTS);
auto dtype = get_allocator_type(hint);
- CachedExtentRef extent;
- // for extents that would be stored in NVDIMM/PMEM, no delayed
- // allocation is needed
- if (need_delayed_allocation(dtype)) {
- // set a unique temperary paddr, this is necessary because
- // transaction's write_set is indexed by paddr
- extent = cache.alloc_new_extent_by_type(t, type, length, true);
- } else {
- extent = cache.alloc_new_extent_by_type(t, type, length);
- }
+ bool delay = can_delay_allocation(dtype);
+ CachedExtentRef extent = cache.alloc_new_extent_by_type(
+ t, type, length, delay);
extent->backend_type = dtype;
extent->hint = hint;
return extent;
Transaction& t,
segment_off_t length,
placement_hint_t hint = placement_hint_t::NONE) {
+ // 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);
- TCachedExtentRef<T> extent;
- if (need_delayed_allocation(dtype)) {
- // set a unique temperary paddr, this is necessary because
- // transaction's write_set is indexed by paddr
- extent = cache.alloc_new_extent<T>(t, length, true);
- } else {
- extent = cache.alloc_new_extent<T>(t, length);
- }
+ bool delay = can_delay_allocation(dtype);
+ TCachedExtentRef<T> extent = cache.alloc_new_extent<T>(
+ t, length, delay);
extent->backend_type = dtype;
extent->hint = hint;
return extent;
NUM_TYPES
};
-bool need_delayed_allocation(device_type_t type);
+bool can_delay_allocation(device_type_t type);
/* Monotonically increasing identifier for the location of a
* journal_record.
};
constexpr auto EXTENT_TYPES_MAX = static_cast<uint8_t>(extent_types_t::NONE);
-inline bool is_logical_type(extent_types_t type) {
+constexpr bool is_logical_type(extent_types_t type) {
switch (type) {
case extent_types_t::ROOT:
case extent_types_t::LADDR_INTERNAL: