summaryrefslogtreecommitdiffstats
path: root/src/crimson/os/seastore/transaction.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/crimson/os/seastore/transaction.h')
-rw-r--r--src/crimson/os/seastore/transaction.h91
1 files changed, 28 insertions, 63 deletions
diff --git a/src/crimson/os/seastore/transaction.h b/src/crimson/os/seastore/transaction.h
index 5d8ad00ba22..cd8c333c69f 100644
--- a/src/crimson/os/seastore/transaction.h
+++ b/src/crimson/os/seastore/transaction.h
@@ -8,16 +8,17 @@
#include <boost/intrusive/list.hpp>
#include "crimson/common/log.h"
+#include "crimson/os/seastore/backref_entry.h"
+#include "crimson/os/seastore/cached_extent.h"
#include "crimson/os/seastore/logging.h"
#include "crimson/os/seastore/ordering_handle.h"
-#include "crimson/os/seastore/seastore_types.h"
-#include "crimson/os/seastore/cached_extent.h"
#include "crimson/os/seastore/root_block.h"
+#include "crimson/os/seastore/seastore_types.h"
+#include "crimson/os/seastore/transaction_interruptor.h"
namespace crimson::os::seastore {
class SeaStore;
-class Transaction;
struct io_stat_t {
uint64_t num = 0;
@@ -408,12 +409,14 @@ public:
src_t src,
journal_seq_t initiated_after,
on_destruct_func_t&& f,
- transaction_id_t trans_id
+ transaction_id_t trans_id,
+ cache_hint_t cache_hint
) : weak(weak),
handle(std::move(handle)),
on_destruct(std::move(f)),
src(src),
- trans_id(trans_id)
+ trans_id(trans_id),
+ cache_hint(cache_hint)
{}
void invalidate_clear_write_set() {
@@ -460,6 +463,7 @@ public:
ool_write_stats = {};
rewrite_stats = {};
conflicted = false;
+ assert(backref_entries.empty());
if (!has_reset) {
has_reset = true;
}
@@ -571,10 +575,23 @@ public:
return pre_alloc_list;
}
+ cache_hint_t get_cache_hint() const {
+ return cache_hint;
+ }
+
private:
friend class Cache;
friend Ref make_test_transaction();
+ void set_backref_entries(backref_entry_refs_t&& entries) {
+ assert(backref_entries.empty());
+ backref_entries = std::move(entries);
+ }
+
+ backref_entry_refs_t move_backref_entries() {
+ return std::move(backref_entries);
+ }
+
/**
* If set, *this may not be used to perform writes and will not provide
* consistentency allowing operations using to avoid maintaining a read_set.
@@ -669,6 +686,10 @@ private:
transaction_id_t trans_id = TRANS_ID_NULL;
seastar::lw_shared_ptr<rbm_pending_ool_t> pending_ool;
+
+ backref_entry_refs_t backref_entries;
+
+ cache_hint_t cache_hint = CACHE_HINT_TOUCH;
};
using TransactionRef = Transaction::Ref;
@@ -681,67 +702,11 @@ inline TransactionRef make_test_transaction() {
Transaction::src_t::MUTATE,
JOURNAL_SEQ_NULL,
[](Transaction&) {},
- ++next_id
+ ++next_id,
+ CACHE_HINT_TOUCH
);
}
-struct TransactionConflictCondition {
- class transaction_conflict final : public std::exception {
- public:
- const char* what() const noexcept final {
- return "transaction conflict detected";
- }
- };
-
-public:
- TransactionConflictCondition(Transaction &t) : t(t) {}
-
- template <typename Fut>
- std::optional<Fut> may_interrupt() {
- if (t.conflicted) {
- return seastar::futurize<Fut>::make_exception_future(
- transaction_conflict());
- } else {
- return std::optional<Fut>();
- }
- }
-
- template <typename T>
- static constexpr bool is_interruption_v =
- std::is_same_v<T, transaction_conflict>;
-
-
- static bool is_interruption(std::exception_ptr& eptr) {
- return *eptr.__cxa_exception_type() == typeid(transaction_conflict);
- }
-
-private:
- Transaction &t;
-};
-
-using trans_intr = crimson::interruptible::interruptor<
- TransactionConflictCondition
- >;
-
-template <typename E>
-using trans_iertr =
- crimson::interruptible::interruptible_errorator<
- TransactionConflictCondition,
- E
- >;
-
-template <typename F, typename... Args>
-auto with_trans_intr(Transaction &t, F &&f, Args&&... args) {
- return trans_intr::with_interruption_to_error<crimson::ct_error::eagain>(
- std::move(f),
- TransactionConflictCondition(t),
- t,
- std::forward<Args>(args)...);
-}
-
-template <typename T>
-using with_trans_ertr = typename T::base_ertr::template extend<crimson::ct_error::eagain>;
-
}
#if FMT_VERSION >= 90000