]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: move LogicalCachedExtent to cached_extent.h
authorSamuel Just <sjust@redhat.com>
Tue, 30 Jun 2020 21:17:00 +0000 (14:17 -0700)
committerSamuel Just <sjust@redhat.com>
Thu, 16 Jul 2020 23:16:42 +0000 (16:16 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/cached_extent.cc
src/crimson/os/seastore/cached_extent.h
src/crimson/os/seastore/lba_manager.cc
src/crimson/os/seastore/lba_manager.h
src/crimson/os/seastore/transaction_manager.h

index e901913975a151d61ed31bbe6910f96ffc7f543b..cbe730871e602cb148a8ba29c7c894dea88d2f9e 100644 (file)
@@ -65,4 +65,21 @@ CachedExtent::~CachedExtent()
   }
 }
 
+std::ostream &operator<<(std::ostream &out, const LBAPin &rhs)
+{
+  return out << "LBAPin(" << rhs.get_laddr() << "~" << rhs.get_length()
+            << "->" << rhs.get_paddr();
+}
+
+std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs)
+{
+  bool first = true;
+  out << '[';
+  for (auto &i: rhs) {
+    out << (first ? "" : ",") << *i;
+    first = false;
+  }
+  return out << ']';
+}
+
 }
index 7ab52f0fa63396af2412c37685a63b8f90836d11..66d8e46858cb4309b6037b69849ddfc3bae9f394 100644 (file)
@@ -495,5 +495,86 @@ public:
   }
 };
 
+class LBAPin;
+using LBAPinRef = std::unique_ptr<LBAPin>;
+class LBAPin {
+public:
+  virtual extent_len_t get_length() const = 0;
+  virtual paddr_t get_paddr() const = 0;
+  virtual laddr_t get_laddr() const = 0;
+  virtual LBAPinRef duplicate() const = 0;
+
+  virtual ~LBAPin() {}
+};
+std::ostream &operator<<(std::ostream &out, const LBAPin &rhs);
+
+using lba_pin_list_t = std::list<LBAPinRef>;
+
+std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs);
+
+
+/**
+ * LogicalCachedExtent
+ *
+ * CachedExtent with associated lba mapping.
+ *
+ * Users of TransactionManager should be using extents derived from
+ * LogicalCachedExtent.
+ */
+class LogicalCachedExtent : public CachedExtent {
+public:
+  template <typename... T>
+  LogicalCachedExtent(T&&... t) : CachedExtent(std::forward<T>(t)...) {}
+
+  void set_pin(LBAPinRef &&pin) { this->pin = std::move(pin); }
+
+  LBAPin &get_pin() {
+    assert(pin);
+    return *pin;
+  }
+
+  laddr_t get_laddr() const {
+    assert(pin);
+    return pin->get_laddr();
+  }
+
+  void apply_delta_and_adjust_crc(
+    paddr_t base, const ceph::bufferlist &bl) final {
+    apply_delta(bl);
+    set_last_committed_crc(get_crc32c());
+  }
+protected:
+  virtual void apply_delta(const ceph::bufferlist &bl) = 0;
+
+private:
+  LBAPinRef pin;
+};
+
+using LogicalCachedExtentRef = TCachedExtentRef<LogicalCachedExtent>;
+struct ref_laddr_cmp {
+  using is_transparent = laddr_t;
+  bool operator()(const LogicalCachedExtentRef &lhs,
+                 const LogicalCachedExtentRef &rhs) const {
+    return lhs->get_laddr() < rhs->get_laddr();
+  }
+  bool operator()(const laddr_t &lhs,
+                 const LogicalCachedExtentRef &rhs) const {
+    return lhs < rhs->get_laddr();
+  }
+  bool operator()(const LogicalCachedExtentRef &lhs,
+                 const laddr_t &rhs) const {
+    return lhs->get_laddr() < rhs;
+  }
+};
+
+using lextent_set_t = addr_extent_set_base_t<
+  laddr_t,
+  LogicalCachedExtentRef,
+  ref_laddr_cmp
+  >;
+
+template <typename T>
+using lextent_list_t = addr_extent_list_base_t<
+  laddr_t, TCachedExtentRef<T>>;
 
 }
index 2fe1345cf8f029164e007875c086cffe425ce12e..73411dcf7e3acaa6aae9223320e0a74ca3b79da6 100644 (file)
@@ -15,24 +15,3 @@ LBAManagerRef create_lba_manager(
 }
 
 }
-
-namespace crimson::os::seastore {
-
-std::ostream &operator<<(std::ostream &out, const LBAPin &rhs)
-{
-  return out << "LBAPin(" << rhs.get_laddr() << "~" << rhs.get_length()
-            << "->" << rhs.get_paddr();
-}
-
-std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs)
-{
-  bool first = true;
-  out << '[';
-  for (auto &i: rhs) {
-    out << (first ? "" : ",") << *i;
-    first = false;
-  }
-  return out << ']';
-}
-
-};
index 4a6f2e954762f755dc92f40184e0f7a7f35da8f5..fc5d4a271402932799fb62044e3de1ed41c03c8c 100644 (file)
 
 namespace crimson::os::seastore {
 
-class LBAPin;
-using LBAPinRef = std::unique_ptr<LBAPin>;
-class LBAPin {
-public:
-  virtual extent_len_t get_length() const = 0;
-  virtual paddr_t get_paddr() const = 0;
-  virtual laddr_t get_laddr() const = 0;
-  virtual LBAPinRef duplicate() const = 0;
-
-  virtual ~LBAPin() {}
-};
-std::ostream &operator<<(std::ostream &out, const LBAPin &rhs);
-
-using lba_pin_list_t = std::list<LBAPinRef>;
-
-std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs);
-
 /**
  * Abstract interface for managing the logical to physical mapping
  */
index b93019701bda520ad112cb29c827588f92df1d82..149b7049618441d4b3b2c66f1ce98b6cbf448542 100644 (file)
 namespace crimson::os::seastore {
 class Journal;
 
-/**
- * LogicalCachedExtent
- *
- * CachedExtent with associated lba mapping.
- *
- * Users of TransactionManager should be using extents derived from
- * LogicalCachedExtent.
- */
-class LogicalCachedExtent : public CachedExtent {
-public:
-  template <typename... T>
-  LogicalCachedExtent(T&&... t) : CachedExtent(std::forward<T>(t)...) {}
-
-  void set_pin(LBAPinRef &&pin) { this->pin = std::move(pin); }
-
-  LBAPin &get_pin() {
-    assert(pin);
-    return *pin;
-  }
-
-  laddr_t get_laddr() const {
-    assert(pin);
-    return pin->get_laddr();
-  }
-
-  void apply_delta_and_adjust_crc(
-    paddr_t base, const ceph::bufferlist &bl) final {
-    apply_delta(bl);
-    set_last_committed_crc(get_crc32c());
-  }
-protected:
-  virtual void apply_delta(const ceph::bufferlist &bl) = 0;
-
-private:
-  LBAPinRef pin;
-};
-
-using LogicalCachedExtentRef = TCachedExtentRef<LogicalCachedExtent>;
-struct ref_laddr_cmp {
-  using is_transparent = laddr_t;
-  bool operator()(const LogicalCachedExtentRef &lhs,
-                 const LogicalCachedExtentRef &rhs) const {
-    return lhs->get_laddr() < rhs->get_laddr();
-  }
-  bool operator()(const laddr_t &lhs,
-                 const LogicalCachedExtentRef &rhs) const {
-    return lhs < rhs->get_laddr();
-  }
-  bool operator()(const LogicalCachedExtentRef &lhs,
-                 const laddr_t &rhs) const {
-    return lhs->get_laddr() < rhs;
-  }
-};
-
-using lextent_set_t = addr_extent_set_base_t<
-  laddr_t,
-  LogicalCachedExtentRef,
-  ref_laddr_cmp
-  >;
-
-template <typename T>
-using lextent_list_t = addr_extent_list_base_t<
-  laddr_t, TCachedExtentRef<T>>;
-
 /**
  * TransactionManager
  *