]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mempool changes for bitmap allocator 11922/head
authorRamesh Chander <Ramesh.Chander@sandisk.com>
Fri, 11 Nov 2016 20:08:33 +0000 (15:08 -0500)
committerSage Weil <sage@redhat.com>
Fri, 11 Nov 2016 20:08:52 +0000 (15:08 -0500)
[with bstore_balloc -> bluestore_alloc rename by sage]

Signed-off-by: Ramesh Chander <Ramesh.Chander@sandisk.com>
13 files changed:
src/include/mempool.h
src/os/bluestore/Allocator.h
src/os/bluestore/BitAllocator.cc
src/os/bluestore/BitAllocator.h
src/os/bluestore/BitMapAllocator.cc
src/os/bluestore/BitMapAllocator.h
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueStore.cc
src/os/bluestore/StupidAllocator.cc
src/os/bluestore/StupidAllocator.h
src/os/bluestore/bluestore_types.h
src/test/objectstore/Allocator_test.cc
src/test/objectstore/BitAllocator_test.cc

index 7ba83cbdcc59698de52df4c809c9f65dfd6c7631..81d20976adfcdea8ddfc2a0a3cf198611f8eca47 100644 (file)
@@ -146,6 +146,7 @@ namespace mempool {
   f(osd)                             \
   f(bluestore_meta_onode)            \
   f(bluestore_meta_other)            \
+  f(bluestore_alloc)                 \
   f(bluefs)
 
 // give them integer ids
index 340d0b6b7adc6b2c912371d6cc61ac7a3c01100f..40262d5c7ed63d5bad60cc413465a4c91903d1ce 100644 (file)
@@ -41,17 +41,17 @@ public:
    */
   virtual int alloc_extents(uint64_t want_size, uint64_t alloc_unit,
                             uint64_t max_alloc_size, int64_t hint,
-                            std::vector<AllocExtent> *extents, int *count) = 0;
+                            AllocExtentVector *extents, int *count) = 0;
 
   int alloc_extents(uint64_t want_size, uint64_t alloc_unit,
-                    int64_t hint, std::vector<AllocExtent> *extents, int *count) {
+                    int64_t hint, AllocExtentVector *extents, int *count) {
     return alloc_extents(want_size, alloc_unit, want_size, hint, extents, count);
   }
 
   virtual int release(
     uint64_t offset, uint64_t length) = 0;
 
-  virtual int release_extents(std::vector<AllocExtent> *extents, int count) {
+  virtual int release_extents(AllocExtentVector *extents, int count) {
     int res = 0;
       for (int i = 0; i < count; i++) {
         res = release((*extents)[i].offset, (*extents)[i].length);
index 993d5f9b7ca8556a4751e716a6cfddbf509c928c..99745e18f15c0a5efbcc40922c8947b2dd229cdb 100644 (file)
 #include <assert.h>
 #include <math.h>
 
+MEMPOOL_DEFINE_OBJECT_FACTORY(BitMapArea, BitMapArea, bluestore_alloc);
+MEMPOOL_DEFINE_OBJECT_FACTORY(BitMapAreaIN, BitMapAreaIN, bluestore_alloc);
+MEMPOOL_DEFINE_OBJECT_FACTORY(BitMapAreaLeaf, BitMapAreaLeaf, bluestore_alloc);
+MEMPOOL_DEFINE_OBJECT_FACTORY(BitMapZone, BitMapZone, bluestore_alloc);
+MEMPOOL_DEFINE_OBJECT_FACTORY(BmapEntry, BmapEntry, bluestore_alloc);
+MEMPOOL_DEFINE_OBJECT_FACTORY(BitAllocator, BitAllocator, bluestore_alloc);
+
 int64_t BitMapAreaLeaf::count = 0;
 int64_t BitMapZone::count = 0;
 int64_t BitMapZone::total_blocks = 0;
@@ -350,7 +357,7 @@ void BitMapZone::init(int64_t zone_num, int64_t total_blocks, bool def)
   alloc_assert(total_blocks < std::numeric_limits<int32_t>::max());
   alloc_assert(!(total_blocks % BmapEntry::size()));
 
-  std::vector<BmapEntry> *bmaps = new std::vector<BmapEntry> (num_bmaps, BmapEntry(def));
+  BmapEntryVector *bmaps = new BmapEntryVector(num_bmaps, BmapEntry(def));
   m_bmap_list = bmaps;
   incr_count();
 }
index 2a0916c5ebf4c9510651453bedb40c765b2efd16..8b601a27f0a50abad52cce628dc4cb147a19a766 100644 (file)
@@ -26,6 +26,7 @@
 #define alloc_dbg_assert(x) (static_cast<void> (0))
 #endif
 
+
 class BitAllocatorStats {
 public:
   std::atomic<int64_t> m_total_alloc_calls;
@@ -71,7 +72,8 @@ public:
 
 template <class BitMapEntity>
 class BitMapEntityIter {
-  std::vector<BitMapEntity> *m_list;
+  typedef mempool::bluestore_alloc::vector<BitMapEntity> BitMapEntityVector;
+  BitMapEntityVector *m_list;
   int64_t m_start_idx;
   int64_t m_cur_idx;
   bool m_wrap;
@@ -79,7 +81,7 @@ class BitMapEntityIter {
   bool m_end;
 public:
 
-  void init(std::vector<BitMapEntity> *list, bool wrap, int64_t start_idx) {
+  void init(BitMapEntityVector *list, bool wrap, int64_t start_idx) {
     m_list = list;
     m_wrap = wrap;
     m_start_idx = start_idx;
@@ -88,10 +90,10 @@ public:
     m_end = false;
   }
 
-  BitMapEntityIter(std::vector<BitMapEntity> *list, int64_t start_idx) {
+  BitMapEntityIter(BitMapEntityVector *list, int64_t start_idx) {
     init(list, false, start_idx);
   }
-  BitMapEntityIter(std::vector<BitMapEntity> *list, int64_t start_idx, bool wrap) {
+  BitMapEntityIter(BitMapEntityVector *list, int64_t start_idx, bool wrap) {
     init(list, wrap, start_idx);
   }
 
@@ -145,6 +147,7 @@ private:
   bmap_t m_bits;
 
 public:
+  MEMPOOL_CLASS_HELPERS();
   static bmap_t full_bmask();
   static int64_t size();
   static bmap_t empty_bmask();
@@ -194,6 +197,7 @@ protected:
   bmap_area_type_t m_type;
 
 public:
+  MEMPOOL_CLASS_HELPERS();
   static int64_t get_zone_size();
   static int64_t get_span_size();
   bmap_area_type_t level_to_type(int level);
@@ -313,14 +317,17 @@ public:
   void decr_idx();
 };
 
+typedef mempool::bluestore_alloc::vector<BmapEntry> BmapEntryVector;
+
 class BitMapZone: public BitMapArea{
 
 private:
   std::atomic<int32_t> m_used_blocks;
-  std::vector <BmapEntry> *m_bmap_list;
+  BmapEntryVector *m_bmap_list;
   std::mutex m_lock;
 
 public:
+  MEMPOOL_CLASS_HELPERS();
   static int64_t count;
   static int64_t total_blocks;
   static void incr_count() { count++;}
@@ -419,6 +426,7 @@ protected:
         int64_t blk_off, ExtentList *block_list);  
 
 public:
+  MEMPOOL_CLASS_HELPERS();
   BitMapAreaIN();
   BitMapAreaIN(int64_t zone_num, int64_t total_blocks);
   BitMapAreaIN(int64_t zone_num, int64_t total_blocks, bool def);
@@ -458,6 +466,7 @@ private:
             bool def);
 
 public:
+  MEMPOOL_CLASS_HELPERS();
   static int64_t count;
   static void incr_count() { count++;}
   BitMapAreaLeaf() { }
@@ -520,6 +529,7 @@ private:
            int64_t hint, int64_t area_blk_off, ExtentList *block_list);
 
 public:
+  MEMPOOL_CLASS_HELPERS();
 
   BitAllocator(int64_t total_blocks, int64_t zone_size_block, bmap_alloc_mode_t mode);
   BitAllocator(int64_t total_blocks, int64_t zone_size_block, bmap_alloc_mode_t mode, bool def);
index c686ca7ddbcfe739dbb0e9cbd83326fb5e3a47dc..b0b7d036d1bacc82273b38e83121d11b07066055 100644 (file)
@@ -150,7 +150,7 @@ int BitMapAllocator::allocate(
 
 int BitMapAllocator::alloc_extents(
   uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
-  int64_t hint, std::vector<AllocExtent> *extents, int *count)
+  int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents, int *count)
 {
   assert(!(alloc_unit % m_block_size));
   assert(alloc_unit);
@@ -177,7 +177,7 @@ int BitMapAllocator::alloc_extents(
  */
 int BitMapAllocator::alloc_extents_cont(
   uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, int64_t hint,
-  std::vector<AllocExtent> *extents, int *count)
+  mempool::bluestore_alloc::vector<AllocExtent> *extents, int *count)
 {
   *count = 0;
   assert(alloc_unit);
@@ -215,7 +215,7 @@ int BitMapAllocator::alloc_extents_cont(
 
 int BitMapAllocator::alloc_extents_dis(
   uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
-  int64_t hint, std::vector<AllocExtent> *extents, int *count)
+  int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents, int *count)
 {
   ExtentList block_list = ExtentList(extents, m_block_size, max_alloc_size);
   int64_t nblks = (want_size + m_block_size - 1) / m_block_size;
index a478d176835a2e101917259ddd4cf2f8aadf4b2e..629b4185a0b6126a4143dc0df6ac50d5a2b0940c 100644 (file)
@@ -25,10 +25,10 @@ class BitMapAllocator : public Allocator {
   void insert_free(uint64_t offset, uint64_t len);
 
   int alloc_extents_cont(uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
-                         int64_t hint, std::vector<AllocExtent> *extents, int *count);
+                         int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents, int *count);
 
   int alloc_extents_dis(uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
-                        int64_t hint, std::vector<AllocExtent> *extents, int *count);
+                        int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents, int *count);
 
 public:
   BitMapAllocator();
@@ -44,7 +44,7 @@ public:
 
   int alloc_extents(
     uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
-    int64_t hint, std::vector<AllocExtent> *extents, int *count);
+    int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents, int *count);
 
   int release(
     uint64_t offset, uint64_t length);
index 41491a2e0dfb3fe4372500be3c1a1f415f921c55..9d32697343f2ef212620d5566f09f55fa56176ef 100644 (file)
@@ -1748,8 +1748,7 @@ int BlueFS::_allocate(uint8_t id, uint64_t len,
   }
 
   int count = 0;
-  std::vector<AllocExtent> extents = 
-        std::vector<AllocExtent>(left / min_alloc_size);
+  AllocExtentVector extents = AllocExtentVector(left / min_alloc_size);
 
   r = alloc[id]->alloc_extents(left, min_alloc_size,
                                hint, &extents, &count);
index 1667f5bf34104914c6e63851b84de2bfde9b2195..f54b49b70501ade0028075696a80477df3a48ba0 100644 (file)
@@ -7882,8 +7882,7 @@ int BlueStore::_do_alloc_write(
     }
 
     int count = 0;
-    std::vector<AllocExtent> extents = 
-                std::vector<AllocExtent>(final_length / min_alloc_size);
+    AllocExtentVector extents = AllocExtentVector(final_length / min_alloc_size);
 
     int r = alloc->alloc_extents(final_length, min_alloc_size, max_alloc_size,
                                  hint, &extents, &count);
index 1f40ae1504c3427bc2cbaff6b2ad9c81a394750b..780c6972eda4867862da904497af45b9d9e93ba3 100644 (file)
@@ -203,8 +203,12 @@ int StupidAllocator::allocate(
 }
 
 int StupidAllocator::alloc_extents(
-  uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
-  int64_t hint, std::vector<AllocExtent> *extents, int *count)
+  uint64_t want_size,
+  uint64_t alloc_unit,
+  uint64_t max_alloc_size,
+  int64_t hint,
+  mempool::bluestore_alloc::vector<AllocExtent> *extents,
+  int *count)
 {
   uint64_t allocated_size = 0;
   uint64_t offset = 0;
index 59ffdcefc811cfa629dc416b94d29a6b16dddabc..69ab47934589b46caf22f8670e9e8335654e602d 100644 (file)
@@ -36,7 +36,7 @@ public:
 
   int alloc_extents(
     uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
-    int64_t hint, std::vector<AllocExtent> *extents, int *count);
+    int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents, int *count);
 
   int allocate(
     uint64_t want_size, uint64_t alloc_unit, int64_t hint,
index 123ad30b35bb48a7040c40f6b731eaf8ba904936..4fca244a0a3d74c3e6875adb6cae946cd0b5f7c2 100644 (file)
@@ -62,6 +62,8 @@ struct bluestore_cnode_t {
 };
 WRITE_CLASS_DENC(bluestore_cnode_t)
 
+class AllocExtent;
+typedef mempool::bluestore_alloc::vector<AllocExtent> AllocExtentVector;
 class AllocExtent {
 public:
   uint64_t offset;
@@ -79,24 +81,24 @@ public:
 };
 
 class ExtentList {
-  std::vector<AllocExtent> *m_extents;
+  AllocExtentVector *m_extents;
   int64_t m_num_extents;
   int64_t m_block_size;
   uint64_t m_max_alloc_size;
 
 public:
-  void init(std::vector<AllocExtent> *extents, int64_t block_size, uint64_t max_alloc_size) {
+  void init(AllocExtentVector *extents, int64_t block_size, uint64_t max_alloc_size) {
     m_extents = extents;
     m_num_extents = 0;
     m_block_size = block_size;
     m_max_alloc_size = max_alloc_size;
   }
 
-  ExtentList(std::vector<AllocExtent> *extents, int64_t block_size) {
+  ExtentList(AllocExtentVector *extents, int64_t block_size) {
     init(extents, block_size, 0);
   }
 
-  ExtentList(std::vector<AllocExtent> *extents, int64_t block_size, uint64_t max_alloc_size) {
+  ExtentList(AllocExtentVector *extents, int64_t block_size, uint64_t max_alloc_size) {
     init(extents, block_size, max_alloc_size);
   }
 
@@ -106,7 +108,7 @@ public:
 
   void add_extents(int64_t start, int64_t count);
 
-  std::vector<AllocExtent> *get_extents() {
+  AllocExtentVector *get_extents() {
     return m_extents;
   }
 
index a003fdbc74460a550b382f72ec5f63dd11043c2c..6b854f3f3a3be511ec07a17e17b642c4b6b09571 100644 (file)
@@ -67,7 +67,7 @@ TEST_P(AllocTest, test_alloc_min_alloc)
   {
     alloc->init_add_free(0, block_size * 4);
     EXPECT_EQ(alloc->reserve(block_size * 4), 0);
-    std::vector<AllocExtent> extents = std::vector<AllocExtent> 
+    AllocExtentVector extents = AllocExtentVector 
                         (4, AllocExtent(0, 0));
   
     EXPECT_EQ(alloc->alloc_extents(4 * (uint64_t)block_size, (uint64_t) block_size, 
@@ -84,7 +84,7 @@ TEST_P(AllocTest, test_alloc_min_alloc)
     alloc->init_add_free(0, block_size * 2);
     alloc->init_add_free(3 * block_size, block_size * 2);
     EXPECT_EQ(alloc->reserve(block_size * 4), 0);
-    std::vector<AllocExtent> extents = std::vector<AllocExtent> 
+    AllocExtentVector extents = AllocExtentVector 
                         (4, AllocExtent(0, 0));
   
     EXPECT_EQ(alloc->alloc_extents(4 * (uint64_t)block_size, (uint64_t) block_size, 
@@ -112,7 +112,7 @@ TEST_P(AllocTest, test_alloc_min_max_alloc)
   {
     alloc->init_add_free(0, block_size * 4);
     EXPECT_EQ(alloc->reserve(block_size * 4), 0);
-    std::vector<AllocExtent> extents = std::vector<AllocExtent> 
+    AllocExtentVector extents = AllocExtentVector 
                         (4, AllocExtent(0, 0));
   
     EXPECT_EQ(alloc->alloc_extents(4 * (uint64_t)block_size, (uint64_t) block_size, 
@@ -131,7 +131,7 @@ TEST_P(AllocTest, test_alloc_min_max_alloc)
   {
     alloc->init_add_free(0, block_size * 4);
     EXPECT_EQ(alloc->reserve(block_size * 4), 0);
-    std::vector<AllocExtent> extents = std::vector<AllocExtent> 
+    AllocExtentVector extents = AllocExtentVector 
                         (2, AllocExtent(0, 0));
   
     EXPECT_EQ(alloc->alloc_extents(4 * (uint64_t)block_size, (uint64_t) block_size, 
@@ -148,7 +148,7 @@ TEST_P(AllocTest, test_alloc_min_max_alloc)
   {
     alloc->init_add_free(0, block_size * 16);
     EXPECT_EQ(alloc->reserve(block_size * 16), 0);
-    std::vector<AllocExtent> extents = std::vector<AllocExtent> 
+    AllocExtentVector extents = AllocExtentVector 
                         (8, AllocExtent(0, 0));
   
     EXPECT_EQ(alloc->alloc_extents(16 * (uint64_t)block_size, (uint64_t) block_size, 
@@ -174,7 +174,7 @@ TEST_P(AllocTest, test_alloc_failure)
     alloc->init_add_free(block_size * 512, block_size * 256);
 
     EXPECT_EQ(alloc->reserve(block_size * 512), 0);
-    std::vector<AllocExtent> extents = std::vector<AllocExtent> 
+    AllocExtentVector extents = AllocExtentVector 
                         (4, AllocExtent(0, 0));
   
     EXPECT_EQ(alloc->alloc_extents(512 * (uint64_t)block_size, (uint64_t) block_size * 256, 
@@ -201,7 +201,7 @@ TEST_P(AllocTest, test_alloc_hint_bmap)
   init_alloc(blocks, 1);
   alloc->init_add_free(0, blocks);
 
-  auto extents = std::vector<AllocExtent>
+  auto extents = AllocExtentVector
           (zone_size * 4, AllocExtent(-1, -1));
   alloc->reserve(blocks);
 
index 5ebec8ea53c8c8e68a7fe8a8351d9ad4cdfd6c79..16f12fff97dd41125a527185048338c33b147d34 100644 (file)
@@ -49,7 +49,7 @@ TEST(BitAllocator, test_bmap_iter)
   };
   BmapEntityTmp *obj = NULL;
   int i = 0;
-  std::vector<BmapEntityTmp> *arr = new std::vector<BmapEntityTmp>(num_items);
+  mempool::bstore_balloc::vector<BmapEntityTmp> *arr = new mempool::bstore_balloc::vector<BmapEntityTmp>(num_items);
   for (i = 0; i < num_items; i++) {
     (*arr)[i].init(i);
   }
@@ -91,7 +91,7 @@ TEST(BitAllocator, test_bmap_iter)
   num_items = 4;
   off = num_items - 1;
 
-  arr = new std::vector<BmapEntityTmp>(num_items);
+  arr = new mempool::bstore_balloc::vector<BmapEntityTmp>(num_items);
   for (i = 0; i < num_items; i++) {
     (*arr)[i].init(i);
   }
@@ -364,7 +364,7 @@ TEST(BitAllocator, test_zone_alloc)
   }
 
   int64_t blk_size = 1024;
-  std::vector<AllocExtent> extents = std::vector<AllocExtent>
+  AllocExtentVector extents = AllocExtentVector
         (zone->size() / 2, AllocExtent(-1, -1));
 
   ExtentList *block_list = new ExtentList(&extents, blk_size);
@@ -388,7 +388,7 @@ TEST(BitAllocator, test_zone_alloc)
 
   {
     int64_t blk_size = 1024;
-    std::vector<AllocExtent> extents = std::vector<AllocExtent>
+    AllocExtentVector extents = AllocExtentVector
       (zone->size() / 2, AllocExtent(-1, -1));
 
     ExtentList *block_list = new ExtentList(&extents, blk_size);
@@ -486,7 +486,7 @@ TEST(BitAllocator, test_bmap_alloc)
     }
 
     int64_t blk_size = 1024;
-    auto extents = std::vector<AllocExtent>
+    auto extents = AllocExtentVector
           (alloc->size(), AllocExtent(-1, -1));
 
     ExtentList *block_list = new ExtentList(&extents, blk_size);
@@ -584,7 +584,7 @@ bool alloc_extents_max_block(BitAllocator *alloc,
   int64_t allocated = 0;
   int64_t verified = 0;
   int64_t count = 0;
-  std::vector<AllocExtent> extents = std::vector<AllocExtent>
+  AllocExtentVector extents = AllocExtentVector
         (total_alloc, AllocExtent(-1, -1));
 
   ExtentList *block_list = new ExtentList(&extents, blk_size, max_alloc);
@@ -671,7 +671,7 @@ do_work_dis(BitAllocator *alloc)
   int64_t alloced = 0;
   int64_t num_blocks = alloc->size() / NUM_THREADS;
 
-  std::vector<AllocExtent> extents = std::vector<AllocExtent>
+  AllocExtentVector extents = AllocExtentVector
         (num_blocks, AllocExtent(-1, -1));
   ExtentList *block_list = new ExtentList(&extents, 4096);