]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use interval_set<...,btree_map<...>>
authorSage Weil <sage@redhat.com>
Sat, 28 Oct 2017 21:20:43 +0000 (16:20 -0500)
committerIgor Fedotov <ifedotov@suse.com>
Thu, 12 Apr 2018 18:34:28 +0000 (21:34 +0300)
This avoid the code duplication, yay!

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 762dd42971a9ced62ea5617f7cd6b0e0fd2ef74c)

src/os/bluestore/StupidAllocator.cc
src/os/bluestore/StupidAllocator.h
src/test/common/test_interval_set.cc

index 19cb308426998aee6238a7401fd1589b17423b18..0fc8a0e1479edaae0e1c7707f5e90d9d007ba128 100644 (file)
@@ -72,7 +72,7 @@ void StupidAllocator::unreserve(uint64_t unused)
 
 /// return the effective length of the extent if we align to alloc_unit
 uint64_t StupidAllocator::_aligned_len(
-  btree_interval_set<uint64_t,allocator>::iterator p,
+  StupidAllocator::interval_set_t::iterator p,
   uint64_t alloc_unit)
 {
   uint64_t skew = p.get_start() % alloc_unit;
@@ -285,10 +285,10 @@ void StupidAllocator::init_rm_free(uint64_t offset, uint64_t length)
   std::lock_guard<std::mutex> l(lock);
   dout(10) << __func__ << " 0x" << std::hex << offset << "~" << length
           << std::dec << dendl;
-  btree_interval_set<uint64_t,allocator> rm;
+  interval_set_t rm;
   rm.insert(offset, length);
   for (unsigned i = 0; i < free.size() && !rm.empty(); ++i) {
-    btree_interval_set<uint64_t,allocator> overlap;
+    interval_set_t overlap;
     overlap.intersection_of(rm, free[i]);
     if (!overlap.empty()) {
       dout(20) << __func__ << " bin " << i << " rm 0x" << std::hex << overlap
index 431c636a61022a82eca8b88143ff12d39e4e53ca..bcce0823216442e9c72eba04a738e26c6cbe03a3 100644 (file)
@@ -7,7 +7,8 @@
 #include <mutex>
 
 #include "Allocator.h"
-#include "include/btree_interval_set.h"
+#include "include/btree_map.h"
+#include "include/interval_set.h"
 #include "os/bluestore/bluestore_types.h"
 #include "include/mempool.h"
 
@@ -19,8 +20,10 @@ class StupidAllocator : public Allocator {
   int64_t num_reserved; ///< reserved bytes
 
   typedef mempool::bluestore_alloc::pool_allocator<
-    pair<const uint64_t,uint64_t>> allocator;
-  std::vector<btree_interval_set<uint64_t,allocator>> free;  ///< leading-edge copy
+    pair<const uint64_t,uint64_t>> allocator_t;
+  typedef btree::btree_map<uint64_t,uint64_t,std::less<uint64_t>,allocator_t> interval_set_map_t;
+  typedef interval_set<uint64_t,interval_set_map_t> interval_set_t;
+  std::vector<interval_set_t> free;  ///< leading-edge copy
 
   uint64_t last_alloc;
 
@@ -28,7 +31,7 @@ class StupidAllocator : public Allocator {
   void _insert_free(uint64_t offset, uint64_t len);
 
   uint64_t _aligned_len(
-    btree_interval_set<uint64_t,allocator>::iterator p,
+    interval_set_t::iterator p,
     uint64_t alloc_unit);
 
 public:
index ca723125610df65466e119bd35f27b431e2f4801..7a85588bbbc663710c1c959922536737cf52ced8 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <gtest/gtest.h>
 #include "include/interval_set.h"
-#include "include/btree_interval_set.h"
+#include "include/btree_map.h"
 
 using namespace ceph;
 
@@ -29,7 +29,11 @@ class IntervalSetTest : public ::testing::Test {
   typedef T ISet;
 };
 
-typedef ::testing::Types< interval_set<IntervalValueType> ,  btree_interval_set<IntervalValueType> > IntervalSetTypes;
+typedef ::testing::Types<
+  interval_set<IntervalValueType>,
+  interval_set<IntervalValueType,
+              btree::btree_map<IntervalValueType,IntervalValueType>>
+  > IntervalSetTypes;
 
 TYPED_TEST_CASE(IntervalSetTest, IntervalSetTypes);