]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/onode-staged-tree: free resources when call submit_transaction()
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 19 May 2021 08:26:10 +0000 (16:26 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 21 May 2021 06:47:56 +0000 (14:47 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/onode_manager/staged-fltree/node.cc
src/crimson/os/seastore/onode_manager/staged-fltree/tree.h
src/crimson/os/seastore/onode_manager/staged-fltree/value.cc
src/crimson/os/seastore/onode_manager/staged-fltree/value.h
src/crimson/os/seastore/seastore.cc

index 2ca3ea2bd891e18adac56a1baaf6fb85bf147601..ee520bdcd7694888b2ae914c261f9fcbcf23a38a 100644 (file)
@@ -2062,6 +2062,10 @@ void LeafNode::validate_cursor(const tree_cursor_t& cursor) const
   assert(this == cursor.get_leaf_node().get());
   assert(cursor.is_tracked());
   assert(!impl->is_extent_retired());
+
+  // We need to make sure user has freed all the cursors before submitting the
+  // according transaction. Otherwise the below checks will have undefined
+  // behaviors.
   auto [key, p_value_header] = get_kv(cursor.get_position());
   auto magic = p_value_header->magic;
   assert(key.compare_to(cursor.get_key_view(magic)) == MatchKindCMP::EQ);
index 17f14dd149b51ca11db5774d7d7e83179166373a..db7920c33f996d38639a76efab14f2620252e7f3 100644 (file)
@@ -23,6 +23,9 @@
  * - Runs above seastore block and transaction layer;
  * - Specially optimized for onode key structures and seastore
  *   delta/transaction semantics;
+ *
+ * Note: User should not hold any Cursor/Value when call
+ * submit_transaction() because of validations implemented in ~tree_cursor_t().
  */
 
 namespace crimson::os::seastore::onode {
@@ -68,6 +71,11 @@ class Btree {
       }
     }
 
+    /// Invalidate the Cursor before submitting transaction.
+    void invalidate() {
+      p_cursor.reset();
+    }
+
     // XXX: return key_view_t to avoid unecessary ghobject_t constructions
     ghobject_t get_ghobj() const {
       assert(!is_end());
index 18eebf718240066667ae880a8fcf14019ff65d50..cd4bba0e39380a55078e87c1b01219f71477cbad 100644 (file)
@@ -36,6 +36,11 @@ bool Value::is_tracked() const
   return p_cursor->is_tracked();
 }
 
+void Value::invalidate()
+{
+  p_cursor.reset();
+}
+
 eagain_future<> Value::extend(Transaction& t, value_size_t extend_size)
 {
   assert(is_tracked());
index fe7126f7a98639031d5cb60b002f26271f3b30f5..95f675d33ad903f621b9f1a685b8e214092cf929 100644 (file)
@@ -171,6 +171,9 @@ class Value {
   /// Returns whether the Value is still tracked in tree.
   bool is_tracked() const;
 
+  /// Invalidate the Value before submitting transaction.
+  void invalidate();
+
   /// Returns the value payload size.
   value_size_t get_payload_size() const {
     assert(is_tracked());
index e286a173b808bc84d45342051da07e184a36e54c..cbbf8db70e8b336979be66bf2870340c3e244097 100644 (file)
@@ -605,6 +605,10 @@ seastar::future<> SeaStore::do_transaction(
       }).safe_then([this, &ctx] {
        return onode_manager->write_dirty(*ctx.transaction, ctx.onodes);
       }).safe_then([this, &ctx] {
+        // There are some validations in onode tree during onode value
+        // destruction in debug mode, which need to be done before calling
+        // submit_transaction().
+        ctx.onodes.clear();
        return transaction_manager->submit_transaction(std::move(ctx.transaction));
       }).safe_then([&ctx]() {
        for (auto i : {