From 05d68ddc1582985931010479b11ccd7a05a7ff0d Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Fri, 8 Oct 2021 10:33:28 +0800 Subject: [PATCH] crimson/os/seastore/epm: misc cleanup Signed-off-by: Yingxin Cheng --- .../os/seastore/extent_placement_manager.h | 26 ++++++------------- src/crimson/os/seastore/seastore_types.cc | 3 ++- src/crimson/os/seastore/seastore_types.h | 4 +-- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/crimson/os/seastore/extent_placement_manager.h b/src/crimson/os/seastore/extent_placement_manager.h index 2e368fb302d..4bd917eda08 100644 --- a/src/crimson/os/seastore/extent_placement_manager.h +++ b/src/crimson/os/seastore/extent_placement_manager.h @@ -312,16 +312,9 @@ public: 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; @@ -334,16 +327,13 @@ public: 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 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, length, true); - } else { - extent = cache.alloc_new_extent(t, length); - } + bool delay = can_delay_allocation(dtype); + TCachedExtentRef extent = cache.alloc_new_extent( + t, length, delay); extent->backend_type = dtype; extent->hint = hint; return extent; diff --git a/src/crimson/os/seastore/seastore_types.cc b/src/crimson/os/seastore/seastore_types.cc index 5b18e4f55d1..6e5558be4c9 100644 --- a/src/crimson/os/seastore/seastore_types.cc +++ b/src/crimson/os/seastore/seastore_types.cc @@ -198,7 +198,8 @@ ceph::bufferlist encode_record( return bl; } -bool need_delayed_allocation(device_type_t type) { +bool can_delay_allocation(device_type_t type) { + // Some types of device may not support delayed allocation, for example PMEM. return type <= RANDOM_BLOCK; } diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h index 1ccadaf964d..f912f6979cf 100644 --- a/src/crimson/os/seastore/seastore_types.h +++ b/src/crimson/os/seastore/seastore_types.h @@ -257,7 +257,7 @@ enum device_type_t { 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. @@ -367,7 +367,7 @@ enum class extent_types_t : uint8_t { }; constexpr auto EXTENT_TYPES_MAX = static_cast(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: -- 2.39.5