]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: set root block to clean at the initialization phase
authorXuehan Xu <xxhdx1985126@gmail.com>
Fri, 13 Aug 2021 13:51:10 +0000 (21:51 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Wed, 8 Sep 2021 03:03:01 +0000 (11:03 +0800)
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h

index 18905214a4cc5dbb0df227a9a02e5cc8c63cbe53..f095982adeb8b54e26709209dfc3bc416f67bcb5 100644 (file)
@@ -593,11 +593,13 @@ void Cache::replace_extent(CachedExtentRef next, CachedExtentRef prev)
   extents.replace(*next, *prev);
 
   if (prev->get_type() == extent_types_t::ROOT) {
-    assert(prev->primary_ref_list_hook.is_linked());
-    assert(prev->is_dirty());
-    stats.dirty_bytes -= prev->get_length();
-    dirty.erase(dirty.s_iterator_to(*prev));
-    intrusive_ptr_release(&*prev);
+    assert(prev->is_clean()
+      || prev->primary_ref_list_hook.is_linked());
+    if (prev->is_dirty()) {
+      stats.dirty_bytes -= prev->get_length();
+      dirty.erase(dirty.s_iterator_to(*prev));
+      intrusive_ptr_release(&*prev);
+    }
     add_to_dirty(next);
   } else if (prev->is_dirty()) {
     assert(prev->get_dirty_from() == next->get_dirty_from());
@@ -980,7 +982,7 @@ void Cache::init() {
     root = nullptr;
   }
   root = new RootBlock();
-  root->state = CachedExtent::extent_state_t::DIRTY;
+  root->state = CachedExtent::extent_state_t::CLEAN;
   add_extent(root);
 }
 
@@ -1022,6 +1024,7 @@ Cache::replay_delta(
     remove_extent(root);
     root->apply_delta_and_adjust_crc(record_base, delta.bl);
     root->dirty_from_or_retired_at = journal_seq;
+    root->state = CachedExtent::extent_state_t::DIRTY;
     add_extent(root);
     return replay_delta_ertr::now();
   } else {
index d808a7d7bc1b01eb5075a861299310b102e8d59a..a265c601e0fa59a761da005baf042d2d63b72523 100644 (file)
@@ -496,6 +496,9 @@ public:
     Transaction &t,
     F &&f)
   {
+    // journal replay should has been finished at this point,
+    // Cache::root should have been inserted to the dirty list
+    assert(root->is_dirty());
     std::vector<CachedExtentRef> dirty;
     for (auto &e : extents) {
       dirty.push_back(CachedExtentRef(&e));