]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/so/seastore: clarify ExtentIndex clear()
authorSamuel Just <sjust@redhat.com>
Fri, 10 Sep 2021 01:07:31 +0000 (18:07 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 13 Sep 2021 20:02:36 +0000 (13:02 -0700)
ExtentIndex::clear() needs to handle clearing parent_index.

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

index a72d5166339b983e713ea659ca23e041556ca2f3..56a1d4361ace3c4e402f8504ef1d7b5e2efb9fcd 100644 (file)
@@ -550,14 +550,13 @@ public:
     );
   }
 
-  template <typename Disposer>
-  void clear_and_dispose(Disposer disposer) {
-    extent_index.clear_and_dispose(disposer);
-    bytes = 0;
-  }
-
   void clear() {
-    extent_index.clear();
+    struct cached_extent_disposer {
+      void operator() (CachedExtent* extent) {
+       extent->parent_index = nullptr;
+      }
+    };
+    extent_index.clear_and_dispose(cached_extent_disposer());
     bytes = 0;
   }
 
index 34d1b10ba0d10fa7cb91922dc8e644fe81f2cfc0..99920916e641d83edd91abf3c2ecbae15c497be3 100644 (file)
@@ -24,12 +24,6 @@ class Transaction;
  * Representation of in-progress mutation. Used exclusively through Cache methods.
  */
 class Transaction {
-  struct cached_extent_disposer {
-    void operator() (CachedExtent* extent) {
-      extent->parent_index = nullptr;
-      extent->state = CachedExtent::extent_state_t::INVALID;
-    }
-  };
 public:
   using Ref = std::unique_ptr<Transaction>;
   using on_destruct_func_t = std::function<void(Transaction&)>;
@@ -213,10 +207,16 @@ public:
       src(src)
   {}
 
+  void invalidate_clear_write_set() {
+    for (auto &&i: write_set) {
+      i.state = CachedExtent::extent_state_t::INVALID;
+    }
+    write_set.clear();
+  }
 
   ~Transaction() {
     on_destruct(*this);
-    write_set.clear_and_dispose(cached_extent_disposer());
+    invalidate_clear_write_set();
   }
 
   friend class crimson::os::seastore::SeaStore;
@@ -227,7 +227,7 @@ public:
     offset = 0;
     delayed_temp_offset = 0;
     read_set.clear();
-    write_set.clear_and_dispose(cached_extent_disposer());
+    invalidate_clear_write_set();
     fresh_block_list.clear();
     mutated_block_list.clear();
     delayed_alloc_list.clear();