]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/async_cleaner: move ExtentCallbackInterface out of the class
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 25 Aug 2022 13:11:31 +0000 (21:11 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 26 Aug 2022 09:47:30 +0000 (17:47 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/async_cleaner.h
src/crimson/os/seastore/extent_placement_manager.h
src/crimson/os/seastore/transaction_manager.h

index a44eb709e0c3f683386b508068347a0edfb4c908..b7965b5b6c5ab9280b6221baf1d8b2b054123c0b 100644 (file)
@@ -265,6 +265,133 @@ private:
 
 std::ostream &operator<<(std::ostream &, const segments_info_t &);
 
+/**
+ * Callback interface for querying extents and operating on transactions.
+ */
+class ExtentCallbackInterface {
+public:
+  virtual ~ExtentCallbackInterface() = default;
+
+  /// Creates empty transaction
+  /// weak transaction should be type READ
+  virtual TransactionRef create_transaction(
+      Transaction::src_t, const char *name, bool is_weak=false) = 0;
+
+  /// Creates empty transaction with interruptible context
+  template <typename Func>
+  auto with_transaction_intr(
+      Transaction::src_t src,
+      const char* name,
+      Func &&f) {
+    return do_with_transaction_intr<Func, false>(
+        src, name, std::forward<Func>(f));
+  }
+
+  template <typename Func>
+  auto with_transaction_weak(
+      const char* name,
+      Func &&f) {
+    return do_with_transaction_intr<Func, true>(
+        Transaction::src_t::READ, name, std::forward<Func>(f)
+    ).handle_error(
+      crimson::ct_error::eagain::handle([] {
+        ceph_assert(0 == "eagain impossible");
+      }),
+      crimson::ct_error::pass_further_all{}
+    );
+  }
+
+  /// See Cache::get_next_dirty_extents
+  using get_next_dirty_extents_iertr = trans_iertr<
+    crimson::errorator<
+      crimson::ct_error::input_output_error>
+    >;
+  using get_next_dirty_extents_ret = get_next_dirty_extents_iertr::future<
+    std::vector<CachedExtentRef>>;
+  virtual get_next_dirty_extents_ret get_next_dirty_extents(
+    Transaction &t,     ///< [in] current transaction
+    journal_seq_t bound,///< [in] return extents with dirty_from < bound
+    size_t max_bytes    ///< [in] return up to max_bytes of extents
+  ) = 0;
+
+  using extent_mapping_ertr = crimson::errorator<
+    crimson::ct_error::input_output_error,
+    crimson::ct_error::eagain>;
+  using extent_mapping_iertr = trans_iertr<
+    crimson::errorator<
+      crimson::ct_error::input_output_error>
+    >;
+
+  /**
+   * rewrite_extent
+   *
+   * Updates t with operations moving the passed extents to a new
+   * segment.  extent may be invalid, implementation must correctly
+   * handle finding the current instance if it is still alive and
+   * otherwise ignore it.
+   */
+  using rewrite_extent_iertr = extent_mapping_iertr;
+  using rewrite_extent_ret = rewrite_extent_iertr::future<>;
+  virtual rewrite_extent_ret rewrite_extent(
+    Transaction &t,
+    CachedExtentRef extent,
+    reclaim_gen_t target_generation,
+    sea_time_point modify_time) = 0;
+
+  /**
+   * get_extent_if_live
+   *
+   * Returns extent at specified location if still referenced by
+   * lba_manager and not removed by t.
+   *
+   * See TransactionManager::get_extent_if_live and
+   * LBAManager::get_physical_extent_if_live.
+   */
+  using get_extents_if_live_iertr = extent_mapping_iertr;
+  using get_extents_if_live_ret = get_extents_if_live_iertr::future<
+    std::list<CachedExtentRef>>;
+  virtual get_extents_if_live_ret get_extents_if_live(
+    Transaction &t,
+    extent_types_t type,
+    paddr_t addr,
+    laddr_t laddr,
+    seastore_off_t len) = 0;
+
+  /**
+   * submit_transaction_direct
+   *
+   * Submits transaction without any space throttling.
+   */
+  using submit_transaction_direct_iertr = trans_iertr<
+    crimson::errorator<
+      crimson::ct_error::input_output_error>
+    >;
+  using submit_transaction_direct_ret =
+    submit_transaction_direct_iertr::future<>;
+  virtual submit_transaction_direct_ret submit_transaction_direct(
+    Transaction &t,
+    std::optional<journal_seq_t> seq_to_trim = std::nullopt) = 0;
+
+private:
+  template <typename Func, bool IsWeak>
+  auto do_with_transaction_intr(
+      Transaction::src_t src,
+      const char* name,
+      Func &&f) {
+    return seastar::do_with(
+      create_transaction(src, name, IsWeak),
+      [f=std::forward<Func>(f)](auto &ref_t) mutable {
+        return with_trans_intr(
+          *ref_t,
+          [f=std::forward<Func>(f)](auto& t) mutable {
+            return f(t);
+          }
+        );
+      }
+    );
+  }
+};
+
 /**
  * Callback interface for journal trimming
  */
@@ -633,131 +760,6 @@ public:
     }
   };
 
-  /// Callback interface for querying and operating on segments
-  class ExtentCallbackInterface {
-  public:
-    virtual ~ExtentCallbackInterface() = default;
-
-    /// Creates empty transaction
-    /// weak transaction should be type READ
-    virtual TransactionRef create_transaction(
-        Transaction::src_t, const char *name, bool is_weak=false) = 0;
-
-    /// Creates empty transaction with interruptible context
-    template <typename Func>
-    auto with_transaction_intr(
-        Transaction::src_t src,
-        const char* name,
-        Func &&f) {
-      return do_with_transaction_intr<Func, false>(
-          src, name, std::forward<Func>(f));
-    }
-
-    template <typename Func>
-    auto with_transaction_weak(
-        const char* name,
-        Func &&f) {
-      return do_with_transaction_intr<Func, true>(
-          Transaction::src_t::READ, name, std::forward<Func>(f)
-      ).handle_error(
-        crimson::ct_error::eagain::handle([] {
-          ceph_assert(0 == "eagain impossible");
-        }),
-        crimson::ct_error::pass_further_all{}
-      );
-    }
-
-    /// See Cache::get_next_dirty_extents
-    using get_next_dirty_extents_iertr = trans_iertr<
-      crimson::errorator<
-        crimson::ct_error::input_output_error>
-      >;
-    using get_next_dirty_extents_ret = get_next_dirty_extents_iertr::future<
-      std::vector<CachedExtentRef>>;
-    virtual get_next_dirty_extents_ret get_next_dirty_extents(
-      Transaction &t,     ///< [in] current transaction
-      journal_seq_t bound,///< [in] return extents with dirty_from < bound
-      size_t max_bytes    ///< [in] return up to max_bytes of extents
-    ) = 0;
-
-    using extent_mapping_ertr = crimson::errorator<
-      crimson::ct_error::input_output_error,
-      crimson::ct_error::eagain>;
-    using extent_mapping_iertr = trans_iertr<
-      crimson::errorator<
-       crimson::ct_error::input_output_error>
-      >;
-
-    /**
-     * rewrite_extent
-     *
-     * Updates t with operations moving the passed extents to a new
-     * segment.  extent may be invalid, implementation must correctly
-     * handle finding the current instance if it is still alive and
-     * otherwise ignore it.
-     */
-    using rewrite_extent_iertr = extent_mapping_iertr;
-    using rewrite_extent_ret = rewrite_extent_iertr::future<>;
-    virtual rewrite_extent_ret rewrite_extent(
-      Transaction &t,
-      CachedExtentRef extent,
-      reclaim_gen_t target_generation,
-      sea_time_point modify_time) = 0;
-
-    /**
-     * get_extent_if_live
-     *
-     * Returns extent at specified location if still referenced by
-     * lba_manager and not removed by t.
-     *
-     * See TransactionManager::get_extent_if_live and
-     * LBAManager::get_physical_extent_if_live.
-     */
-    using get_extents_if_live_iertr = extent_mapping_iertr;
-    using get_extents_if_live_ret = get_extents_if_live_iertr::future<
-      std::list<CachedExtentRef>>;
-    virtual get_extents_if_live_ret get_extents_if_live(
-      Transaction &t,
-      extent_types_t type,
-      paddr_t addr,
-      laddr_t laddr,
-      seastore_off_t len) = 0;
-
-    /**
-     * submit_transaction_direct
-     *
-     * Submits transaction without any space throttling.
-     */
-    using submit_transaction_direct_iertr = trans_iertr<
-      crimson::errorator<
-        crimson::ct_error::input_output_error>
-      >;
-    using submit_transaction_direct_ret =
-      submit_transaction_direct_iertr::future<>;
-    virtual submit_transaction_direct_ret submit_transaction_direct(
-      Transaction &t,
-      std::optional<journal_seq_t> seq_to_trim = std::nullopt) = 0;
-
-  private:
-    template <typename Func, bool IsWeak>
-    auto do_with_transaction_intr(
-        Transaction::src_t src,
-        const char* name,
-        Func &&f) {
-      return seastar::do_with(
-        create_transaction(src, name, IsWeak),
-        [f=std::forward<Func>(f)](auto &ref_t) mutable {
-          return with_trans_intr(
-            *ref_t,
-            [f=std::forward<Func>(f)](auto& t) mutable {
-              return f(t);
-            }
-          );
-        }
-      );
-    }
-  };
-
 private:
   const bool detailed;
   const config_t config;
index 60b3e2476db94f73add3796a7fbf92780a6ea9b4..db29a714e5da9a2beea3c468c3c88a0ba92bd22d 100644 (file)
@@ -94,7 +94,7 @@ public:
 
   void set_primary_device(Device *device);
 
-  void set_extent_callback(AsyncCleaner::ExtentCallbackInterface *cb) {
+  void set_extent_callback(ExtentCallbackInterface *cb) {
     cleaner->set_extent_callback(cb);
   }
 
index 61fe024788db974978cfeccde2586e8f005c6972..18cf0aed644c636a12677765d948c997eef1a94b 100644 (file)
@@ -58,7 +58,7 @@ auto repeat_eagain(F &&f) {
  * Abstraction hiding reading and writing to persistence.
  * Exposes transaction based interface with read isolation.
  */
-class TransactionManager : public AsyncCleaner::ExtentCallbackInterface {
+class TransactionManager : public ExtentCallbackInterface {
 public:
   using base_ertr = Cache::base_ertr;
   using base_iertr = Cache::base_iertr;
@@ -82,15 +82,6 @@ public:
   using close_ertr = base_ertr;
   close_ertr::future<> close();
 
-  /// Creates empty transaction
-  /// weak transaction should be type READ
-  TransactionRef create_transaction(
-      Transaction::src_t src,
-      const char* name,
-      bool is_weak=false) final {
-    return cache->create_transaction(src, name, is_weak);
-  }
-
   /// Resets transaction
   void reset_transaction_preserve_handle(Transaction &t) {
     return cache->reset_transaction_preserve_handle(t);
@@ -462,12 +453,6 @@ public:
   using submit_transaction_iertr = base_iertr;
   submit_transaction_iertr::future<> submit_transaction(Transaction &);
 
-  /// AsyncCleaner::ExtentCallbackInterface
-  using AsyncCleaner::ExtentCallbackInterface::submit_transaction_direct_ret;
-  submit_transaction_direct_ret submit_transaction_direct(
-    Transaction &t,
-    std::optional<journal_seq_t> seq_to_trim = std::nullopt) final;
-
   /**
    * flush
    *
@@ -477,20 +462,37 @@ public:
    */
   seastar::future<> flush(OrderingHandle &handle);
 
-  using AsyncCleaner::ExtentCallbackInterface::get_next_dirty_extents_ret;
+  /*
+   * ExtentCallbackInterface
+   */
+
+  /// weak transaction should be type READ
+  TransactionRef create_transaction(
+      Transaction::src_t src,
+      const char* name,
+      bool is_weak=false) final {
+    return cache->create_transaction(src, name, is_weak);
+  }
+
+  using ExtentCallbackInterface::submit_transaction_direct_ret;
+  submit_transaction_direct_ret submit_transaction_direct(
+    Transaction &t,
+    std::optional<journal_seq_t> seq_to_trim = std::nullopt) final;
+
+  using ExtentCallbackInterface::get_next_dirty_extents_ret;
   get_next_dirty_extents_ret get_next_dirty_extents(
     Transaction &t,
     journal_seq_t seq,
     size_t max_bytes) final;
 
-  using AsyncCleaner::ExtentCallbackInterface::rewrite_extent_ret;
+  using ExtentCallbackInterface::rewrite_extent_ret;
   rewrite_extent_ret rewrite_extent(
     Transaction &t,
     CachedExtentRef extent,
     reclaim_gen_t target_generation,
     sea_time_point modify_time) final;
 
-  using AsyncCleaner::ExtentCallbackInterface::get_extents_if_live_ret;
+  using ExtentCallbackInterface::get_extents_if_live_ret;
   get_extents_if_live_ret get_extents_if_live(
     Transaction &t,
     extent_types_t type,