From 618ea258b6651745210fcc54699d4b39aba24f4e Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 5 Sep 2017 13:35:47 +0200 Subject: [PATCH] os/bluestore: make the StupidAllocator aware about bulk releases. Signed-off-by: Radoslaw Zarzynski (cherry picked from commit cb0420ea0b343e7659807b33389ff2354a1319ed) --- src/os/bluestore/StupidAllocator.cc | 16 ++++++++++++++++ src/os/bluestore/StupidAllocator.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/os/bluestore/StupidAllocator.cc b/src/os/bluestore/StupidAllocator.cc index 65d7baf59d8b..6aa527fe9538 100644 --- a/src/os/bluestore/StupidAllocator.cc +++ b/src/os/bluestore/StupidAllocator.cc @@ -250,6 +250,22 @@ void StupidAllocator::release( num_free += length; } +void StupidAllocator::release( + const interval_set& release_set) +{ + std::lock_guard l(lock); + for (interval_set::const_iterator p = release_set.begin(); + p != release_set.end(); + ++p) { + const auto offset = p.get_start(); + const auto length = p.get_len(); + ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length + << std::dec << dendl; + _insert_free(offset, length); + num_free += length; + } +} + uint64_t StupidAllocator::get_free() { std::lock_guard l(lock); diff --git a/src/os/bluestore/StupidAllocator.h b/src/os/bluestore/StupidAllocator.h index bcce08232164..d432868b38a7 100644 --- a/src/os/bluestore/StupidAllocator.h +++ b/src/os/bluestore/StupidAllocator.h @@ -51,6 +51,8 @@ public: void release( uint64_t offset, uint64_t length) override; + void release( + const interval_set& release_set) override; uint64_t get_free() override; -- 2.47.3