]> git.apps.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)
committerSage Weil <sage@redhat.com>
Sat, 28 Oct 2017 21:25:05 +0000 (16:25 -0500)
This avoid the code duplication, yay!

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/StupidAllocator.cc
src/os/bluestore/StupidAllocator.h
src/test/common/test_interval_set.cc

index 0c28fa1730afef4385a29e5bafba03e848ab4134..41962bca6c1a7daf5564eb070308d8d93a595658 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;
@@ -292,10 +292,10 @@ void StupidAllocator::init_rm_free(uint64_t offset, uint64_t length)
   std::lock_guard<std::mutex> l(lock);
   ldout(cct, 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()) {
       ldout(cct, 20) << __func__ << " bin " << i << " rm 0x" << std::hex << overlap
index c8e6b28120f394bd485316aed772b3b93b9a63bb..ccf0f0ec14b60b391003c326cff80cd18976738b 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);