From 0b41d2372e2f27bdffc033b88fc4a4ccd550da12 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 5 Sep 2017 12:55:34 +0200 Subject: [PATCH] os/bluestore: extend the Allocator interface with bulk releases. Signed-off-by: Radoslaw Zarzynski --- src/os/bluestore/Allocator.h | 12 ++++++++++++ src/os/bluestore/BlueStore.cc | 17 ++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/os/bluestore/Allocator.h b/src/os/bluestore/Allocator.h index a93428d9c1b..62850c4fa60 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 852c6ba14e3..2ead998e6b7 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8201,11 +8201,7 @@ void BlueStore::_txc_release_alloc(TransContext *txc) // update allocator with full released set if (!cct->_conf->bluestore_debug_no_reuse_blocks) { dout(10) << __func__ << " " << txc << " " << txc->released << 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(); @@ -8564,14 +8560,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(); } -- 2.39.5