From: Sage Weil Date: Fri, 17 Mar 2017 21:52:56 +0000 (-0400) Subject: os/bluestore: clean up flush_all() X-Git-Tag: v12.0.1~12^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8fa788ca84f49587f58af7658c9d49d2bb5813d;p=ceph.git os/bluestore: clean up flush_all() Add assertions if we fail to flush everything. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 50deb1c6a175..76d24fa5eaeb 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -742,6 +742,14 @@ BlueStore::Cache *BlueStore::Cache::create(CephContext* cct, string type, return c; } +void BlueStore::Cache::trim_all() +{ + std::lock_guard l(lock); + _trim(0, 0); + assert(_get_num_onodes() == 0); + assert(_get_buffer_bytes() == 0); +} + void BlueStore::Cache::trim( uint64_t target_bytes, float target_meta_ratio, @@ -1152,6 +1160,7 @@ void BlueStore::TwoQCache::_trim(uint64_t onode_max, uint64_t buffer_max) int max_skipped = g_conf->bluestore_cache_trim_max_skip_pinned; while (num > 0) { Onode *o = &*p; + dout(20) << __func__ << " considering " << o << dendl; int refs = o->nref.load(); if (refs > 1) { dout(20) << __func__ << " " << o->oid << " has " << refs @@ -4836,7 +4845,6 @@ int BlueStore::mount() } out_coll: flush_cache(); - coll_map.clear(); out_alloc: _close_alloc(); out_fm: @@ -4873,7 +4881,6 @@ int BlueStore::umount() } _reap_collections(); flush_cache(); - coll_map.clear(); dout(20) << __func__ << " closing" << dendl; mounted = false; @@ -5036,7 +5043,6 @@ int BlueStore::fsck(bool deep) r = bluefs->fsck(); if (r < 0) { flush_cache(); - coll_map.clear(); goto out_alloc; } if (r > 0) @@ -5418,7 +5424,6 @@ int BlueStore::fsck(bool deep) out_scan: flush_cache(); - coll_map.clear(); out_alloc: _close_alloc(); out_fm: @@ -10344,5 +10349,10 @@ void BlueStore::flush_cache() for (auto i : cache_shards) { i->trim_all(); } + for (auto& p : coll_map) { + assert(p.second->onode_map.empty()); + assert(p.second->shared_blob_set.empty()); + } + coll_map.clear(); } // =========================================== diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 11780d87eaa7..a93ae37785bd 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1017,9 +1017,7 @@ public: void trim(uint64_t target_bytes, float target_meta_ratio, float bytes_per_onode); - void trim_all() { - _trim(0, 0); - } + void trim_all(); virtual void _trim(uint64_t onode_max, uint64_t buffer_max) = 0;