From cdde7b6ad767d28126cf4f903f117f1bdeca1e82 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 14 Sep 2016 09:55:08 -0400 Subject: [PATCH] os/bluestore: clear SharedBlob cache in dtor Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 15 +++++++++++++++ src/os/bluestore/BlueStore.h | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 0f15de97242..c9e513a7086 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1177,6 +1177,21 @@ ostream& operator<<(ostream& out, const BlueStore::SharedBlob& sb) return out << ")"; } +BlueStore::SharedBlob::SharedBlob(uint64_t i, const string& k, Cache *c) + : sbid(i), + key(k), + bc(c) +{ +} + +BlueStore::SharedBlob::~SharedBlob() +{ + if (bc.cache) { // the dummy instances have a nullptr + std::lock_guard l(bc.cache->lock); + bc._clear(); + } +} + void BlueStore::SharedBlob::put() { if (--nref == 0) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 2a836f8f729..c90f4d3314d 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -314,10 +314,8 @@ public: BufferSpace bc; ///< buffer cache - SharedBlob(uint64_t i, const string& k, Cache *c) : sbid(i), key(k), bc(c) {} - ~SharedBlob() { - assert(bc.empty()); - } + SharedBlob(uint64_t i, const string& k, Cache *c); + ~SharedBlob(); friend void intrusive_ptr_add_ref(SharedBlob *b) { b->get(); } friend void intrusive_ptr_release(SharedBlob *b) { b->put(); } -- 2.39.5