os/bluestore: simplify SharedBlob::put_ref interface

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
This commit is contained in:
Igor Fedotov 2017-12-27 23:05:45 +03:00
parent b06dd3bb0a
commit 072af9043b
2 changed files with 12 additions and 8 deletions

View File

@ -1691,14 +1691,11 @@ void BlueStore::SharedBlob::get_ref(uint64_t offset, uint32_t length)
void BlueStore::SharedBlob::put_ref(uint64_t offset, uint32_t length,
PExtentVector *r,
set<SharedBlob*> *maybe_unshared)
bool *unshare)
{
assert(persistent);
bool maybe = false;
persistent->ref_map.put(offset, length, r, maybe_unshared ? &maybe : nullptr);
if (maybe_unshared && maybe) {
maybe_unshared->insert(this);
}
persistent->ref_map.put(offset, length, r,
unshare && !*unshare ? unshare : nullptr);
}
// SharedBlobSet
@ -10267,10 +10264,17 @@ void BlueStore::_wctx_finish(
if (blob.is_shared()) {
PExtentVector final;
c->load_shared_blob(b->shared_blob);
bool unshare = false;
bool* unshare_ptr =
!maybe_unshared_blobs || b->is_referenced() ? nullptr : &unshare;
for (auto e : r) {
b->shared_blob->put_ref(
e.offset, e.length, &final,
b->is_referenced() ? nullptr : maybe_unshared_blobs);
unshare_ptr);
}
if (unshare) {
assert(maybe_unshared_blobs);
maybe_unshared_blobs->insert(b->shared_blob.get());
}
dout(20) << __func__ << " shared_blob release " << final
<< " from " << *b->shared_blob << dendl;

View File

@ -402,7 +402,7 @@ public:
/// put logical references, and get back any released extents
void put_ref(uint64_t offset, uint32_t length,
PExtentVector *r, set<SharedBlob*> *maybe_unshared_blobs);
PExtentVector *r, bool *unshare);
friend bool operator==(const SharedBlob &l, const SharedBlob &r) {
return l.get_sbid() == r.get_sbid();