]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: reassign extent_types_t values and remove extent_type_to_index() 42539/head
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 29 Jul 2021 06:52:20 +0000 (14:52 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 30 Jul 2021 01:42:22 +0000 (09:42 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/seastore_types.h

index bc8840e4b248c3c5d8a293ebcefaeb7f6e3e9962..64798edff3556452f6533105cbbde97b21d0d454 100644 (file)
@@ -326,7 +326,7 @@ void Cache::register_metrics()
         }();
         effort_by_ext.fill({});
         for (auto& [ext, ext_label] : labels_by_ext) {
-          auto& effort = effort_by_ext[extent_type_to_index(ext)];
+          auto& effort = get_by_ext(effort_by_ext, ext);
           metrics.add_group(
             "cache",
             {
@@ -350,7 +350,7 @@ void Cache::register_metrics()
       auto& delta_by_ext = efforts.delta_bytes_by_ext;
       delta_by_ext.fill(0);
       for (auto& [ext, ext_label] : labels_by_ext) {
-        auto& value = delta_by_ext[extent_type_to_index(ext)];
+        auto& value = get_by_ext(delta_by_ext, ext);
         metrics.add_group(
           "cache",
           {
index c67b55741bec9922be18a5354e1232725c5619cc..8b1535c4d2ec32ed400c6bad3f35962448e868d4 100644 (file)
@@ -660,7 +660,9 @@ private:
   CounterT& get_by_ext(
       counter_by_extent_t<CounterT>& counters_by_ext,
       extent_types_t ext) {
-    return counters_by_ext[extent_type_to_index(ext)];
+    auto index = static_cast<uint8_t>(ext);
+    assert(index < EXTENT_TYPES_MAX);
+    return counters_by_ext[index];
   }
 
   seastar::metrics::metric_group metrics;
index 1ef052409b9c67916739eb3d81c3498cb90a9097..7d485e7ccd35dbb7e0836844b2c6f20d02a9787e 100644 (file)
@@ -331,40 +331,20 @@ enum class extent_types_t : uint8_t {
   ROOT = 0,
   LADDR_INTERNAL = 1,
   LADDR_LEAF = 2,
-  OMAP_INNER = 4,
-  OMAP_LEAF = 5,
-  ONODE_BLOCK_STAGED = 6,
-  COLL_BLOCK = 7,
-  OBJECT_DATA_BLOCK = 8,
-  RETIRED_PLACEHOLDER = 9,
-
-  RBM_ALLOC_INFO = 0xE0,
+  OMAP_INNER = 3,
+  OMAP_LEAF = 4,
+  ONODE_BLOCK_STAGED = 5,
+  COLL_BLOCK = 6,
+  OBJECT_DATA_BLOCK = 7,
+  RETIRED_PLACEHOLDER = 8,
+  RBM_ALLOC_INFO = 9,
   // Test Block Types
-  TEST_BLOCK = 0xF0,
-  TEST_BLOCK_PHYSICAL = 0xF1,
-
-  // None
-  NONE = 0xFF
+  TEST_BLOCK = 10,
+  TEST_BLOCK_PHYSICAL = 11,
+  // None and the number of valid extent_types_t
+  NONE = 12,
 };
-
-// FIXME: reassign extent_types_t values instead
-inline uint8_t extent_type_to_index(extent_types_t type) {
-  auto value = static_cast<uint8_t>(type);
-  if (value <= 9) {
-    return value;
-  }
-  switch (type) {
-    case extent_types_t::RBM_ALLOC_INFO:
-      return 10;
-    case extent_types_t::TEST_BLOCK:
-      return 11;
-    case extent_types_t::TEST_BLOCK_PHYSICAL:
-      return 12;
-    default:
-      ceph_abort("impossible path");
-  };
-}
-constexpr uint8_t EXTENT_TYPES_MAX = 13;
+constexpr auto EXTENT_TYPES_MAX = static_cast<uint8_t>(extent_types_t::NONE);
 
 inline bool is_logical_type(extent_types_t type) {
   switch (type) {