From: Radoslaw Zarzynski Date: Tue, 5 Sep 2017 10:55:34 +0000 (+0200) Subject: os/bluestore: extend the Allocator interface with bulk releases. X-Git-Tag: v12.2.12~16^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=77810e1812fcf520e1a7f9d3fcf45cabf0eb9b16;p=ceph.git os/bluestore: extend the Allocator interface with bulk releases. Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 0b41d2372e2f27bdffc033b88fc4a4ccd550da12) --- diff --git a/src/os/bluestore/Allocator.h b/src/os/bluestore/Allocator.h index a93428d9c1b8..62850c4fa602 100644 --- a/src/os/bluestore/Allocator.h +++ b/src/os/bluestore/Allocator.h @@ -46,6 +46,18 @@ public: virtual void release( uint64_t offset, uint64_t length) = 0; + /* Bulk release. Implementations may override this method to handle the whole + * set at once. This could save e.g. unnecessary mutex dance. */ + virtual void release(const interval_set& release_set) { + /* TODO(rzarzynski): make this pure virtual and eradicate the single-op + * release() after switching all allocators. */ + for (interval_set::const_iterator p = release_set.begin(); + p != release_set.end(); + ++p) { + release(p.get_start(), p.get_len()); + } + } + virtual void dump() = 0; virtual void init_add_free(uint64_t offset, uint64_t length) = 0; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e6cf86e03195..fde9b123101b 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8533,11 +8533,7 @@ void BlueStore::_txc_release_alloc(TransContext *txc) if (!cct->_conf->bluestore_debug_no_reuse_blocks) { dout(10) << __func__ << " " << txc << " " << std::hex << txc->released << std::dec << dendl; - for (interval_set::iterator p = txc->released.begin(); - p != txc->released.end(); - ++p) { - alloc->release(p.get_start(), p.get_len()); - } + alloc->release(txc->released); } txc->allocated.clear(); @@ -8897,14 +8893,9 @@ void BlueStore::_kv_sync_thread() if (!bluefs_gift_extents.empty()) { _commit_bluefs_freespace(bluefs_gift_extents); } - for (auto p = bluefs_extents_reclaiming.begin(); - p != bluefs_extents_reclaiming.end(); - ++p) { - dout(20) << __func__ << " releasing old bluefs 0x" << std::hex - << p.get_start() << "~" << p.get_len() << std::dec - << dendl; - alloc->release(p.get_start(), p.get_len()); - } + dout(20) << __func__ << " releasing old bluefs 0x" << std::hex + << bluefs_extents_reclaiming << std::dec << dendl; + alloc->release(bluefs_extents_reclaiming); bluefs_extents_reclaiming.clear(); }