]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix false asserts in Cache::trim_all() 15470/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 5 Jun 2017 03:29:39 +0000 (11:29 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 5 Jun 2017 10:08:00 +0000 (18:08 +0800)
These asserts are true if we are going to shutdown the BlueStore instance.
But the caller can also be something like "ceph daemon out/osd.1.asok flush_store_cache",
which can fire these asserts as a result.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index e5bccea2e94d456f0619ec8b03258269f1eddd78..c1ef67fb9e226eaacf064e234e2a14dacd02b8a8 100644 (file)
@@ -747,8 +747,6 @@ void BlueStore::Cache::trim_all()
 {
   std::lock_guard<std::recursive_mutex> l(lock);
   _trim(0, 0);
-  assert(_get_num_onodes() == 0);
-  assert(_get_buffer_bytes() == 0);
 }
 
 void BlueStore::Cache::trim(
@@ -5045,7 +5043,7 @@ int BlueStore::_mount(bool kv_only)
  out_stop:
   _kv_stop();
  out_coll:
-  flush_cache();
+  _flush_cache();
  out_alloc:
   _close_alloc();
  out_fm:
@@ -5074,7 +5072,7 @@ int BlueStore::umount()
   dout(20) << __func__ << " stopping kv thread" << dendl;
   _kv_stop();
   _reap_collections();
-  flush_cache();
+  _flush_cache();
   dout(20) << __func__ << " closing" << dendl;
 
   mounted = false;
@@ -5697,7 +5695,7 @@ int BlueStore::fsck(bool deep)
 
  out_scan:
   mempool_thread.shutdown();
-  flush_cache();
+  _flush_cache();
  out_alloc:
   _close_alloc();
  out_fm:
@@ -11059,11 +11057,12 @@ void BlueStore::generate_db_histogram(Formatter *f)
 
 }
 
-void BlueStore::flush_cache()
+void BlueStore::_flush_cache()
 {
   dout(10) << __func__ << dendl;
   for (auto i : cache_shards) {
     i->trim_all();
+    assert(i->empty());
   }
   for (auto& p : coll_map) {
     assert(p.second->onode_map.empty());
@@ -11072,6 +11071,18 @@ void BlueStore::flush_cache()
   coll_map.clear();
 }
 
+// For external caller.
+// We use a best-effort policy instead, e.g.,
+// we don't care if there are still some pinned onodes/data in the cache
+// after this command is completed.
+void BlueStore::flush_cache()
+{
+  dout(10) << __func__ << dendl;
+  for (auto i : cache_shards) {
+    i->trim_all();
+  }
+}
+
 void BlueStore::_apply_padding(uint64_t head_pad,
                               uint64_t tail_pad,
                               bufferlist& bl,
index f2f3ace5dceafee9a091f52cb25f5a19c5d5e9ff..d95917ede65f0287133e485f812fe3d89b97b956 100644 (file)
@@ -1082,6 +1082,11 @@ public:
                           uint64_t *buffers,
                           uint64_t *bytes) = 0;
 
+    bool empty() {
+      std::lock_guard<std::recursive_mutex> l(lock);
+      return _get_num_onodes() == 0 && _get_buffer_bytes() == 0;
+    }
+
 #ifdef DEBUG_CACHE
     virtual void _audit(const char *s) = 0;
 #else
@@ -2129,6 +2134,7 @@ public:
 
   void get_db_statistics(Formatter *f) override;
   void generate_db_histogram(Formatter *f) override;
+  void _flush_cache();
   void flush_cache() override;
   void dump_perf_counters(Formatter *f) override {
     f->open_object_section("perf_counters");