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
*/
}
};
- /// 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;
* 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;
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);
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
*
*/
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,