]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/epm: misc cleanup
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 8 Oct 2021 02:33:28 +0000 (10:33 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 8 Oct 2021 03:59:42 +0000 (11:59 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/extent_placement_manager.h
src/crimson/os/seastore/seastore_types.cc
src/crimson/os/seastore/seastore_types.h

index 2e368fb302d93f7c0228cc17d06c0d7c03932994..4bd917eda088840947a318472fec93de1dda566e 100644 (file)
@@ -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<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;
index 5b18e4f55d14de99aa4749994d0c8a865ebbafec..6e5558be4c9200110cc22be827d9edb780c62406 100644 (file)
@@ -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;
 }
 
index 1ccadaf964df032ace501da8b47d8990a285623d..f912f6979cfbce44cec4fa0d36dac2a42fc0fa0b 100644 (file)
@@ -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<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: