os/bluestore: clear SharedBlob cache in dtor

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-09-14 09:55:08 -04:00
parent fa0f411029
commit cdde7b6ad7
2 changed files with 17 additions and 4 deletions

View File

@ -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<std::recursive_mutex> l(bc.cache->lock);
bc._clear();
}
}
void BlueStore::SharedBlob::put()
{
if (--nref == 0) {

View File

@ -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(); }