]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/seastore: preserve Transaction::handle on reset for writes
authorSamuel Just <sjust@redhat.com>
Mon, 28 Jun 2021 21:24:44 +0000 (14:24 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 29 Jun 2021 17:14:45 +0000 (10:14 -0700)
We're going to need to preserve the pipeline phase locking on conflict.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/cached_extent.h
src/crimson/os/seastore/seastore.h
src/crimson/os/seastore/transaction.h
src/crimson/os/seastore/transaction_manager.h

index 159b33395c2e1515e4c8829e5ed6ff86f9e7726f..1a9998cc7f2a886a16c81b124b1e6fd285ef044e 100644 (file)
@@ -120,6 +120,11 @@ public:
     return ret;
   }
 
+  /// Resets transaction preserving
+  void reset_transaction_preserve_handle(Transaction &t) {
+    t.reset_preserve_handle(last_commit);
+  }
+
   /**
    * drop_from_cache
    *
index c32d01ade073adfed0c9c051970e7e744c40b35a..856791800b94a3630f5cb96820c5370ce35f07e9 100644 (file)
@@ -635,7 +635,22 @@ public:
       list_hook_options>;
   public:
     token_t(journal_seq_t created_after) : created_after(created_after) {}
-    ~token_t();
+
+    void drop_self();
+    void add_self();
+
+    void reset(journal_seq_t _created_after) {
+      drop_self();
+      created_after = _created_after;
+      add_self();
+    }
+
+    ~token_t() {
+      if (parent) {
+       drop_self();
+       parent = nullptr;
+      }
+    }
   };
 
   void prune() {
@@ -651,7 +666,7 @@ public:
 
   void add_token(token_t &t) {
     t.parent = this;
-    live_tokens.push_back(t);
+    t.add_self();
   }
 
   void add_extent(CachedExtent &extent) {
@@ -664,13 +679,16 @@ private:
   CachedExtent::list retired_extents;
 };
 
-inline retired_extent_gate_t::token_t::~token_t() {
-  if (parent) {
-    parent->live_tokens.erase(
-      parent->live_tokens.s_iterator_to(*this));
-    parent->prune();
-    parent = nullptr;
-  }
+inline void retired_extent_gate_t::token_t::add_self() {
+  assert(parent);
+  parent->live_tokens.push_back(*this);
+}
+
+inline void retired_extent_gate_t::token_t::drop_self() {
+  assert(parent);
+  parent->live_tokens.erase(
+    parent->live_tokens.s_iterator_to(*this));
+  parent->prune();
 }
 
 /**
index f32052a8d008acd41657107c3076e94b0ca11512..c745daf13b3470e20b4e6c8276bcd1f651091724 100644 (file)
@@ -137,8 +137,9 @@ private:
 
     ceph::os::Transaction::iterator iter;
 
-    void reset(TransactionRef &&t) {
-      transaction = std::move(t);
+    template <typename TM>
+    void reset_preserve_handle(TM &tm) {
+      tm->reset_transaction_preserve_handle(*transaction);
       onodes.clear();
       iter = ext_transaction.begin();
     }
@@ -152,11 +153,13 @@ private:
     ceph::os::Transaction &&t,
     F &&f) {
     return seastar::do_with(
-      internal_context_t{ ch, std::move(t) },
+      internal_context_t(
+       ch, std::move(t),
+       transaction_manager->create_transaction()),
       std::forward<F>(f),
       [this](auto &ctx, auto &f) {
        return repeat_eagain([&]() {
-         ctx.reset(transaction_manager->create_transaction());
+         ctx.reset_preserve_handle(transaction_manager);
          return std::invoke(f, ctx);
        }).handle_error(
          crimson::ct_error::eagain::pass_further{},
index b39a20419ce734edf9edd95fceb7383ba69e2d5a..25b437f2770413abbc5245d5ef9f6d43017c9ccf 100644 (file)
@@ -144,6 +144,20 @@ public:
   friend class crimson::os::seastore::SeaStore;
   friend class TransactionConflictCondition;
 
+  void reset_preserve_handle(journal_seq_t initiated_after) {
+    root.reset();
+    offset = 0;
+    read_set.clear();
+    write_set.clear();
+    fresh_block_list.clear();
+    mutated_block_list.clear();
+    retired_set.clear();
+    to_release = NULL_SEG_ID;
+    retired_uncached.clear();
+    retired_gate_token.reset(initiated_after);
+    conflicted = false;
+  }
+
 private:
   friend class Cache;
   friend Ref make_test_transaction();
index f0e588a3078e3eb1d720ddcbcea1862c6447ad6c..38796b720cbd22031b81ec646c3baad1aff0e2c5 100644 (file)
@@ -116,6 +116,11 @@ public:
     return cache->create_weak_transaction();
   }
 
+  /// Resets transaction
+  void reset_transaction_preserve_handle(Transaction &t) {
+    return cache->reset_transaction_preserve_handle(t);
+  }
+
   /**
    * get_pin
    *
@@ -612,6 +617,7 @@ public:
   FORWARD(close)
   FORWARD(create_transaction)
   FORWARD(create_weak_transaction)
+  FORWARD(reset_transaction_preserve_handle)
   INT_FORWARD(get_pin)
   INT_FORWARD(get_pins)
   PARAM_INT_FORWARD(pin_to_extent)