]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: move Transaction::src_t to seastore_types.h
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 21 Jul 2022 07:36:43 +0000 (15:36 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 21 Jul 2022 12:18:59 +0000 (20:18 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/seastore_types.cc
src/crimson/os/seastore/seastore_types.h
src/crimson/os/seastore/transaction.h

index 7e2228953b15e73e84c3942bf9404ae651e3cba0..254af8395c4e8603085dce7f1a32eee40ab4f5da 100644 (file)
@@ -1164,10 +1164,10 @@ private:
   };
 
   template <typename CounterT>
-  using counter_by_src_t = std::array<CounterT, Transaction::SRC_MAX>;
+  using counter_by_src_t = std::array<CounterT, TRANSACTION_TYPE_MAX>;
 
   static constexpr std::size_t NUM_SRC_COMB =
-      Transaction::SRC_MAX * (Transaction::SRC_MAX + 1) / 2;
+      TRANSACTION_TYPE_MAX * (TRANSACTION_TYPE_MAX + 1) / 2;
 
   struct {
     counter_by_src_t<uint64_t> trans_created_by_src;
index a9b0d1c5fd486652097d3c76fcb6a512bbdd4b2a..ea3c63ad764557bb14272657d9ce9649fc25b6ef 100644 (file)
@@ -309,6 +309,28 @@ void record_size_t::account(const delta_info_t& delta)
   plain_mdlength += ceph::encoded_sizeof(delta);
 }
 
+std::ostream &operator<<(std::ostream &os, transaction_type_t type)
+{
+  switch (type) {
+  case transaction_type_t::MUTATE:
+    return os << "MUTATE";
+  case transaction_type_t::READ:
+    return os << "READ";
+  case transaction_type_t::CLEANER_TRIM:
+    return os << "CLEANER_TRIM";
+  case transaction_type_t::TRIM_BACKREF:
+    return os << "TRIM_BACKREF";
+  case transaction_type_t::CLEANER_RECLAIM:
+    return os << "CLEANER_RECLAIM";
+  case transaction_type_t::MAX:
+    return os << "TRANS_TYPE_NULL";
+  default:
+    return os << "INVALID_TRANS_TYPE("
+              << static_cast<std::size_t>(type)
+              << ")";
+  }
+}
+
 std::ostream &operator<<(std::ostream& out, const record_size_t& rsize)
 {
   return out << "record_size_t("
index a14ccaeb277765ff9f30235f94f2755b595b0b34..324c839f316caabb0fb72569a25fccb65b1fb8c0 100644 (file)
@@ -1541,6 +1541,31 @@ struct segment_tail_t {
 };
 std::ostream &operator<<(std::ostream &out, const segment_tail_t &tail);
 
+enum class transaction_type_t : uint8_t {
+  MUTATE = 0,
+  READ, // including weak and non-weak read transactions
+  CLEANER_TRIM,
+  TRIM_BACKREF,
+  CLEANER_RECLAIM,
+  MAX
+};
+
+static constexpr auto TRANSACTION_TYPE_NULL = transaction_type_t::MAX;
+
+static constexpr auto TRANSACTION_TYPE_MAX = static_cast<std::size_t>(
+    transaction_type_t::MAX);
+
+std::ostream &operator<<(std::ostream &os, transaction_type_t type);
+
+constexpr bool is_valid_transaction(transaction_type_t type) {
+  return type < transaction_type_t::MAX;
+}
+
+constexpr bool is_cleaner_transaction(transaction_type_t type) {
+  return (type >= transaction_type_t::CLEANER_TRIM &&
+          type < transaction_type_t::MAX);
+}
+
 struct record_size_t {
   extent_len_t plain_mdlength = 0; // mdlength without the record header
   extent_len_t dlength = 0;
index f81bc62e5f5c5b0af2cb52f5ee5337785162dd1e..2917065b178fee2821c46c8d1c48d808e6e4458b 100644 (file)
@@ -293,15 +293,7 @@ public:
     return ret;
   }
 
-  enum class src_t : uint8_t {
-    MUTATE = 0,
-    READ, // including weak and non-weak read transactions
-    CLEANER_TRIM,
-    TRIM_BACKREF,
-    CLEANER_RECLAIM,
-    MAX
-  };
-  static constexpr auto SRC_MAX = static_cast<std::size_t>(src_t::MAX);
+  using src_t = transaction_type_t;
   src_t get_src() const {
     return src;
   }
@@ -542,29 +534,6 @@ private:
 };
 using TransactionRef = Transaction::Ref;
 
-inline std::ostream& operator<<(std::ostream& os,
-                                const Transaction::src_t& src) {
-  switch (src) {
-  case Transaction::src_t::MUTATE:
-    return os << "MUTATE";
-  case Transaction::src_t::READ:
-    return os << "READ";
-  case Transaction::src_t::CLEANER_TRIM:
-    return os << "CLEANER_TRIM";
-  case Transaction::src_t::TRIM_BACKREF:
-    return os << "TRIM_BACKREF";
-  case Transaction::src_t::CLEANER_RECLAIM:
-    return os << "CLEANER_RECLAIM";
-  default:
-    ceph_abort("impossible");
-  }
-}
-
-constexpr bool is_cleaner_transaction(Transaction::src_t src) {
-  return (src >= Transaction::src_t::CLEANER_TRIM &&
-          src < Transaction::src_t::MAX);
-}
-
 /// Should only be used with dummy staged-fltree node extent manager
 inline TransactionRef make_test_transaction() {
   return std::make_unique<Transaction>(