summaryrefslogtreecommitdiffstats
path: root/src/os/bluestore/BlueStore.cc
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2018-07-12 05:01:47 +0200
committerSage Weil <sage@redhat.com>2018-07-12 05:01:47 +0200
commitd1653a4cbc10c9af2e05facae93079b62652da9e (patch)
tree6e02f2d08b1c91b7788df444ef384cc1dd5065a3 /src/os/bluestore/BlueStore.cc
parentMerge PR #22974 into master (diff)
parentos/bluestore: fix races on SharedBlob::coll in ~SharedBlob. (diff)
downloadceph-d1653a4cbc10c9af2e05facae93079b62652da9e.tar.xz
ceph-d1653a4cbc10c9af2e05facae93079b62652da9e.zip
Merge PR #22972 into master
* refs/pull/22972/head: os/bluestore: fix races on SharedBlob::coll in ~SharedBlob. Reviewed-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src/os/bluestore/BlueStore.cc')
-rw-r--r--src/os/bluestore/BlueStore.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc
index 79d163996ea..93aa79b892a 100644
--- a/src/os/bluestore/BlueStore.cc
+++ b/src/os/bluestore/BlueStore.cc
@@ -1598,11 +1598,6 @@ BlueStore::SharedBlob::SharedBlob(uint64_t i, Collection *_coll)
BlueStore::SharedBlob::~SharedBlob()
{
- if (get_cache()) { // the dummy instances have a nullptr
- std::lock_guard<std::recursive_mutex> l(get_cache()->lock);
- bc._clear(get_cache());
- get_cache()->rm_blob();
- }
if (loaded && persistent) {
delete persistent;
}
@@ -1614,8 +1609,17 @@ void BlueStore::SharedBlob::put()
ldout(coll->store->cct, 20) << __func__ << " " << this
<< " removing self from set " << get_parent()
<< dendl;
- if (get_parent()) {
- get_parent()->remove(this);
+ again:
+ auto coll_snap = coll;
+ if (coll_snap) {
+ std::lock_guard<std::recursive_mutex> l(coll_snap->cache->lock);
+ if (coll_snap != coll) {
+ goto again;
+ }
+ coll_snap->shared_blob_set.remove(this);
+
+ bc._clear(coll_snap->cache);
+ coll_snap->cache->rm_blob();
}
delete this;
}