From 072af9043bd9ca75a1288f0fdd406e2da083c2ea Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Wed, 27 Dec 2017 23:05:45 +0300 Subject: [PATCH] os/bluestore: simplify SharedBlob::put_ref interface Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 18 +++++++++++------- src/os/bluestore/BlueStore.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index ecd0a1bca71..b2625476147 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 *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; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 9bdb12c1711..746bdc97a8d 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 *maybe_unshared_blobs); + PExtentVector *r, bool *unshare); friend bool operator==(const SharedBlob &l, const SharedBlob &r) { return l.get_sbid() == r.get_sbid();