Merge PR into master

* refs/pull/24701/head:
	os/bluestore: fix race between SharedBlobSet::lookup and SharedBlob::put

Reviewed-by: Igor Fedotov <ifedotov@suse.com>
This commit is contained in:
Sage Weil 2018-10-24 10:34:29 -05:00
commit 0638eb1aa4
2 changed files with 9 additions and 3 deletions
src/os/bluestore

View File

@ -1622,8 +1622,10 @@ void BlueStore::SharedBlob::put()
if (coll_snap != coll) {
goto again;
}
coll_snap->shared_blob_set.remove(this);
if (!coll_snap->shared_blob_set.remove(this, true)) {
// race with lookup
return;
}
bc._clear(coll_snap->cache);
coll_snap->cache->rm_blob();
}

View File

@ -461,15 +461,19 @@ public:
sb->coll = coll;
}
void remove(SharedBlob *sb) {
bool remove(SharedBlob *sb, bool verify_nref_is_zero=false) {
std::lock_guard l(lock);
ceph_assert(sb->get_parent() == this);
if (verify_nref_is_zero && sb->nref != 0) {
return false;
}
// only remove if it still points to us
auto p = sb_map.find(sb->get_sbid());
if (p != sb_map.end() &&
p->second == sb) {
sb_map.erase(p);
}
return true;
}
bool empty() {