]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: maintain dirty_from value on dirty CachedExtents
authorSamuel Just <sjust@redhat.com>
Thu, 20 Aug 2020 21:34:55 +0000 (14:34 -0700)
committerSamuel Just <sjust@redhat.com>
Fri, 25 Sep 2020 19:41:03 +0000 (12:41 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/cached_extent.h

index 264a8f24ec919659343a4a9432aa803858869198..3a8b312e4ac8d0bc7d24f8e0bbe790ff92a296e2 100644 (file)
@@ -53,10 +53,10 @@ void Cache::add_extent(CachedExtentRef ref)
   assert(ref->is_valid());
   extents.insert(*ref);
 
-  ceph_assert(!ref->primary_ref_list_hook.is_linked());
   if (ref->is_dirty()) {
-    intrusive_ptr_add_ref(&*ref);
-    dirty.push_back(*ref);
+    add_to_dirty(ref);
+  } else {
+    ceph_assert(!ref->primary_ref_list_hook.is_linked());
   }
   logger().debug("add_extent: {}", *ref);
 }
@@ -79,7 +79,7 @@ void Cache::add_to_dirty(CachedExtentRef ref)
   assert(ref->is_valid());
   assert(!ref->primary_ref_list_hook.is_linked());
   intrusive_ptr_add_ref(&*ref);
-  dirty.push_front(*ref);
+  dirty.push_back(*ref);
 }
 
 void Cache::remove_extent(CachedExtentRef ref)
@@ -105,10 +105,13 @@ void Cache::replace_extent(CachedExtentRef next, CachedExtentRef prev)
 
   if (prev->is_dirty()) {
     ceph_assert(prev->primary_ref_list_hook.is_linked());
-    dirty.insert(dirty.iterator_to(*prev), *next);
-    dirty.erase(dirty.iterator_to(*prev));
+    auto prev_it = dirty.iterator_to(*prev);
+    dirty.insert(prev_it, *next);
+    dirty.erase(prev_it);
     intrusive_ptr_release(&*prev);
     intrusive_ptr_add_ref(&*next);
+  } else {
+    add_to_dirty(next);
   }
 }
 
@@ -265,7 +268,7 @@ void Cache::complete_commit(
     }
     i->state = CachedExtent::extent_state_t::DIRTY;
     if (i->version == 1) {
-      add_to_dirty(i);
+      i->dirty_from = seq;
     }
   }
 
@@ -328,6 +331,9 @@ Cache::replay_delta(paddr_t record_base, const delta_info_t &delta)
        extent->apply_delta_and_adjust_crc(record_base, delta.bl);
        assert(extent->last_committed_crc == delta.final_crc);
 
+       if (extent->version == 0) {
+         extent->dirty_from = journal_seq;
+       }
        extent->version++;
        mark_dirty(extent);
       });
index 46ea4f453013ec87b5a405ceef323b60d736c6bd..a3c44db2e829c19ad096932e9c270b04a5627fba 100644 (file)
@@ -365,7 +365,13 @@ private:
   SegmentManager &segment_manager; ///< ref to segment_manager
   RootBlockRef root;               ///< ref to current root
   ExtentIndex extents;             ///< set of live extents
-  CachedExtent::list dirty;        ///< holds refs to dirty extents
+
+  /**
+   * dirty
+   *
+   * holds refs to dirty extents.  Ordered by CachedExtent::dirty_from.
+   */
+  CachedExtent::list dirty;
 
   /// alloc buffer for cached extent
   bufferptr alloc_cache_buf(size_t size) {
index 052a2dca034dbd9abe5a8d42a87ff4d172481f1a..8c9312a6a92ebfbdd2b2375b05fe57e1fb356313 100644 (file)
@@ -53,6 +53,14 @@ class CachedExtent : public boost::intrusive_ref_counter<
   // Points at current version while in state MUTATION_PENDING
   CachedExtentRef prior_instance;
 
+  /**
+   * dirty_from
+   *
+   * When dirty, indiciates the oldest journal entry which mutates
+   * this extent.
+   */
+  journal_seq_t dirty_from;
+
 public:
   /**
    *  duplicate_for_write
@@ -122,6 +130,7 @@ public:
     out << "CachedExtent(addr=" << this
        << ", type=" << get_type()
        << ", version=" << version
+       << ", dirty_from=" << dirty_from
        << ", paddr=" << get_paddr()
        << ", state=" << state
        << ", last_committed_crc=" << last_committed_crc
@@ -219,6 +228,14 @@ public:
     return state != extent_state_t::INVALID;
   }
 
+  /**
+   * get_dirty_from
+   *
+   * Return journal location of oldest relevant delta.
+   */
+  auto get_dirty_from() const { return dirty_from; }
+
+
   /**
    * get_paddr
    *
@@ -321,6 +338,7 @@ protected:
   CachedExtent(ceph::bufferptr &&ptr) : ptr(std::move(ptr)) {}
   CachedExtent(const CachedExtent &other)
     : state(other.state),
+      dirty_from(other.dirty_from),
       ptr(other.ptr.c_str(), other.ptr.length()),
       version(other.version),
       poffset(other.poffset) {}
@@ -328,6 +346,7 @@ protected:
   struct share_buffer_t {};
   CachedExtent(const CachedExtent &other, share_buffer_t) :
     state(other.state),
+    dirty_from(other.dirty_from),
     ptr(other.ptr),
     version(other.version),
     poffset(other.poffset) {}