]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: Check the cache is clean
authorYin Congmin <congmin.yin@intel.com>
Thu, 16 Sep 2021 11:05:38 +0000 (11:05 +0000)
committerYin Congmin <congmin.yin@intel.com>
Mon, 1 Nov 2021 06:53:40 +0000 (14:53 +0800)
Signed-off-by: Yin Congmin <congmin.yin@intel.com>
src/librbd/cache/pwl/AbstractWriteLog.cc
src/librbd/cache/pwl/AbstractWriteLog.h

index c01d2d411f9da45a8bc90691a2ea219ff75f9db2..5b7799e664b599ab5cbaae21b600d14a2430bcb9 100644 (file)
@@ -624,7 +624,7 @@ void AbstractWriteLog<I>::shut_down(Context *on_finish) {
       }
       {
         std::lock_guard locker(m_lock);
-        ceph_assert(m_dirty_log_entries.size() == 0);
+        check_image_cache_state_clean();
         m_wake_up_enabled = false;
         m_cache_state->clean = true;
         m_log_entries.clear();
@@ -2078,6 +2078,20 @@ bool AbstractWriteLog<I>::can_retire_entry(std::shared_ptr<GenericLogEntry> log_
   return log_entry->can_retire();
 }
 
+template <typename I>
+void AbstractWriteLog<I>::check_image_cache_state_clean() {
+  ceph_assert(m_deferred_ios.empty());
+  ceph_assert(m_ops_to_append.empty());;
+  ceph_assert(m_async_flush_ops == 0);
+  ceph_assert(m_async_append_ops == 0);
+  ceph_assert(m_dirty_log_entries.empty());
+  ceph_assert(m_ops_to_flush.empty());
+  ceph_assert(m_flush_ops_in_flight == 0);
+  ceph_assert(m_flush_bytes_in_flight == 0);
+  ceph_assert(m_bytes_dirty == 0);
+  ceph_assert(m_work_queue.empty());
+}
+
 } // namespace pwl
 } // namespace cache
 } // namespace librbd
index c982d2631fe3f407e6cd009c10f9f71811e039a0..5aeab4c8de4d1e9fc87f0a3d31e4c5a2a511444c 100644 (file)
@@ -234,6 +234,7 @@ private:
 
   void pwl_init(Context *on_finish, pwl::DeferredContexts &later);
   void update_image_cache_state(Context *on_finish);
+  void check_image_cache_state_clean();
 
   void flush_dirty_entries(Context *on_finish);
   bool can_flush_entry(const std::shared_ptr<pwl::GenericLogEntry> log_entry);