]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: report dirty extents usage 42261/head
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 15 Jul 2021 08:24:39 +0000 (16:24 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 20 Jul 2021 08:50:05 +0000 (16:50 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h

index 9a08b20cc3edae834302907e2e2bf5b48d70da14..2f3021e701e6af55c4c8740524a1d193c02c8829 100644 (file)
@@ -446,7 +446,10 @@ void Cache::register_metrics()
 
   /**
    * Cached extents (including placeholders)
+   *
+   * Dirty extents
    */
+  stats.dirty_bytes = 0;
   metrics.add_group(
     "cache",
     {
@@ -466,6 +469,20 @@ void Cache::register_metrics()
         sm::description("total bytes of cached extents"),
         {labels_by_counter.find("BYTES")->second}
       ),
+      sm::make_counter(
+        "dirty_extents",
+        [this] {
+          return dirty.size();
+        },
+        sm::description("total number of dirty extents"),
+        {labels_by_counter.find("EXTENTS")->second}
+      ),
+      sm::make_counter(
+        "dirty_extents",
+        stats.dirty_bytes,
+        sm::description("total bytes of dirty extents"),
+        {labels_by_counter.find("BYTES")->second}
+      ),
     }
   );
 }
@@ -504,12 +521,14 @@ void Cache::add_to_dirty(CachedExtentRef ref)
   assert(!ref->primary_ref_list_hook.is_linked());
   intrusive_ptr_add_ref(&*ref);
   dirty.push_back(*ref);
+  stats.dirty_bytes += ref->get_length();
 }
 
 void Cache::remove_from_dirty(CachedExtentRef ref)
 {
   if (ref->is_dirty()) {
     ceph_assert(ref->primary_ref_list_hook.is_linked());
+    stats.dirty_bytes -= ref->get_length();
     dirty.erase(dirty.s_iterator_to(*ref));
     intrusive_ptr_release(&*ref);
   } else {
@@ -551,6 +570,7 @@ void Cache::replace_extent(CachedExtentRef next, CachedExtentRef 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);
     add_to_dirty(next);
@@ -919,9 +939,11 @@ Cache::close_ertr::future<> Cache::close()
   root.reset();
   for (auto i = dirty.begin(); i != dirty.end(); ) {
     auto ptr = &*i;
+    stats.dirty_bytes -= ptr->get_length();
     dirty.erase(i++);
     intrusive_ptr_release(ptr);
   }
+  assert(stats.dirty_bytes == 0);
   return close_ertr::now();
 }
 
index 6d2d86d14fe338e513dbc4c4063cb3038724a01c..7d556a3d55f6c2c2c465fcd674b809019f2634f7 100644 (file)
@@ -652,6 +652,7 @@ private:
                        boost::hash<src_ext_t>> cache_query;
     uint64_t read_transactions_successful;
     effort_t read_effort_successful;
+    uint64_t dirty_bytes;
   } stats;
 
   template <typename CounterT>