]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hint in extent_alloc code
authorRamesh Chander <Ramesh.Chander@sandisk.com>
Mon, 29 Aug 2016 16:06:38 +0000 (09:06 -0700)
committerRamesh Chander <Ramesh.Chander@sandisk.com>
Wed, 7 Sep 2016 15:05:48 +0000 (08:05 -0700)
Signed-off-by: Ramesh Chander <Ramesh.Chander@sandisk.com>
src/os/bluestore/BitAllocator.cc
src/os/bluestore/BitAllocator.h
src/os/bluestore/BitMapAllocator.cc

index 63489038b4e7ec9318fc137417a86a86ddef5b62..9f649e251dc039e460b67ed5093650cfd895d8dd 100644 (file)
@@ -597,11 +597,12 @@ void BitMapZone::free_blocks(int64_t start_block, int64_t num_blocks)
  * Allocate N blocks, dis-contiguous are fine
  */
 int64_t BitMapZone::alloc_blocks_dis(int64_t num_blocks,
+                                          int64_t hint,
                                    int64_t zone_blk_off, 
                                    ExtentList *alloc_blocks)
 {
-  int64_t bmap_idx = 0;
-  int bit = 0;
+  int64_t bmap_idx = hint / BmapEntry::size();
+  int bit = hint % BmapEntry::size();
   BmapEntry *bmap = NULL;
   int64_t allocated = 0;
   int64_t blk_off = 0;
@@ -619,6 +620,7 @@ int64_t BitMapZone::alloc_blocks_dis(int64_t num_blocks,
     if (allocated == num_blocks) {
       break;
     }
+       bit = 0;
   }
 
   add_used_blocks(allocated);
@@ -920,14 +922,14 @@ exit:
 }
 
 int64_t BitMapAreaIN::alloc_blocks_dis_int(bool wait, int64_t num_blocks,
-           int64_t area_blk_off, ExtentList *block_list)
+           int64_t hint, int64_t area_blk_off, ExtentList *block_list)
 {
   BitMapArea *child = NULL;
   int64_t allocated = 0;
   int64_t blk_off = 0;
 
   BmapEntityListIter iter = BmapEntityListIter(
-        m_child_list, 0, true);
+        m_child_list, hint / m_child_size_blocks, true);
 
   while ((child = (BitMapArea *) iter.next())) {
     if (!child_check_n_lock(child, 1)) {
@@ -936,7 +938,8 @@ int64_t BitMapAreaIN::alloc_blocks_dis_int(bool wait, int64_t num_blocks,
 
     blk_off = child->get_index() * m_child_size_blocks + area_blk_off;
     allocated += child->alloc_blocks_dis(wait, num_blocks - allocated,
-                            blk_off, block_list);
+                            hint % m_child_size_blocks, blk_off, block_list);
+       hint = 0;
     child_unlock(child);
     if (allocated == num_blocks) {
       break;
@@ -947,12 +950,12 @@ int64_t BitMapAreaIN::alloc_blocks_dis_int(bool wait, int64_t num_blocks,
 }
 
 int64_t BitMapAreaIN::alloc_blocks_dis(bool wait, int64_t num_blocks,
-           int64_t blk_off, ExtentList *block_list)
+           int64_t hint, int64_t blk_off, ExtentList *block_list)
 {
   int64_t allocated = 0;
 
   lock_shared();
-  allocated += alloc_blocks_dis_int(wait, num_blocks, blk_off, block_list);
+  allocated += alloc_blocks_dis_int(wait, num_blocks, hint, blk_off, block_list);
   add_used_blocks(allocated);
 
   unlock();
@@ -1147,14 +1150,14 @@ int64_t BitMapAreaLeaf::alloc_blocks_int(bool wait, bool wrap,
 }
 
 int64_t BitMapAreaLeaf::alloc_blocks_dis_int(bool wait, int64_t num_blocks,
-                                 int64_t area_blk_off, ExtentList *block_list)
+                                 int64_t hint, int64_t area_blk_off, ExtentList *block_list)
 {
   BitMapArea *child = NULL;
   int64_t allocated = 0;
   int64_t blk_off = 0;
 
   BmapEntityListIter iter = BmapEntityListIter(
-        m_child_list, 0, false);
+        m_child_list, hint / m_child_size_blocks, false);
 
   while ((child = (BitMapArea *) iter.next())) {
     if (!child_check_n_lock(child, 1, false)) {
@@ -1162,7 +1165,8 @@ int64_t BitMapAreaLeaf::alloc_blocks_dis_int(bool wait, int64_t num_blocks,
     }
 
     blk_off = child->get_index() * m_child_size_blocks + area_blk_off;
-    allocated += child->alloc_blocks_dis(num_blocks - allocated, blk_off, block_list);
+    allocated += child->alloc_blocks_dis(num_blocks - allocated, hint, blk_off, block_list);
+       hint = 0;
     child_unlock(child);
     if (allocated == num_blocks) {
       break;
@@ -1524,17 +1528,17 @@ void BitAllocator::set_blocks_used(int64_t start_block, int64_t num_blocks)
 /*
  * Allocate N dis-contiguous blocks.
  */
-int64_t BitAllocator::alloc_blocks_dis(int64_t num_blocks, ExtentList *block_list)
+int64_t BitAllocator::alloc_blocks_dis(int64_t num_blocks, int64_t hint, ExtentList *block_list)
 {
-  return alloc_blocks_dis_work(num_blocks, block_list, false);
+  return alloc_blocks_dis_work(num_blocks, hint, block_list, false);
 }
 
-int64_t BitAllocator::alloc_blocks_dis_res(int64_t num_blocks, ExtentList *block_list)
+int64_t BitAllocator::alloc_blocks_dis_res(int64_t num_blocks, int64_t hint, ExtentList *block_list)
 {
-  return alloc_blocks_dis_work(num_blocks, block_list, true);
+  return alloc_blocks_dis_work(num_blocks, hint, block_list, true);
 }
 
-int64_t BitAllocator::alloc_blocks_dis_work(int64_t num_blocks, ExtentList *block_list, bool reserved)
+int64_t BitAllocator::alloc_blocks_dis_work(int64_t num_blocks, int64_t hint, ExtentList *block_list, bool reserved)
 {
   int scans = 1;
   int64_t allocated = 0;
@@ -1563,7 +1567,7 @@ int64_t BitAllocator::alloc_blocks_dis_work(int64_t num_blocks, ExtentList *bloc
   }
 
   while (scans && allocated < num_blocks) {
-    allocated += alloc_blocks_dis_int(false, num_blocks - allocated, blk_off, block_list);
+    allocated += alloc_blocks_dis_int(false, num_blocks - allocated, hint + allocated, blk_off, block_list);
     scans--;
   }
 
@@ -1577,7 +1581,7 @@ int64_t BitAllocator::alloc_blocks_dis_work(int64_t num_blocks, ExtentList *bloc
     unlock();
     lock_excl();
     serial_lock();
-    allocated += alloc_blocks_dis_int(false, num_blocks - allocated, blk_off, block_list);
+    allocated += alloc_blocks_dis_int(false, num_blocks - allocated, hint + allocated, blk_off, block_list);
     if (is_stats_on()) {
       m_stats->add_serial_scans(1);
     }
index 52027951dd1f27d6dea22c806fe30430d5d7d531..f006dc80c14a2369025f0f42de1f11c93fe13279 100644 (file)
@@ -236,12 +236,12 @@ public:
   }
 
   virtual int64_t alloc_blocks_dis(bool wait, int64_t num_blocks,
-             int64_t blk_off, ExtentList *block_list) {
+             int64_t hint, int64_t blk_off, ExtentList *block_list) {
     debug_assert(0);
     return 0;
   }
   virtual int64_t alloc_blocks_dis(int64_t num_blocks,
-             int64_t blk_off, ExtentList *block_list) {
+             int64_t hint, int64_t blk_off, ExtentList *block_list) {
     debug_assert(0);
     return 0;
   }
@@ -354,14 +354,14 @@ public:
   }
 
   virtual int64_t alloc_blocks_dis(bool wait, int64_t num_blocks,
-             int64_t blk_off, int64_t *block_list) {
+             int64_t hint, int64_t blk_off, int64_t *block_list) {
     debug_assert(0);
     return 0;
   }
 
   int64_t alloc_blocks(int64_t num_blocks, int64_t *start_block);
   using BitMapArea::alloc_blocks_dis;
-  int64_t alloc_blocks_dis(int64_t num_blocks,
+  int64_t alloc_blocks_dis(int64_t num_blocks, int64_t hint,
         int64_t blk_off, ExtentList *block_list);  
   void set_blocks_used(int64_t start_block, int64_t num_blocks);
 
@@ -427,9 +427,9 @@ public:
   using BitMapArea::alloc_blocks; //non-wait version
   using BitMapArea::alloc_blocks_dis; //non-wait version
   virtual int64_t alloc_blocks(bool wait, int64_t num_blocks, int64_t *start_block);
-  virtual int64_t alloc_blocks_dis_int(bool wait, int64_t num_blocks,
+  virtual int64_t alloc_blocks_dis_int(bool wait, int64_t num_blocks, int64_t hint,
         int64_t blk_off, ExtentList *block_list);  
-  virtual int64_t alloc_blocks_dis(bool wait, int64_t num_blocks,
+  virtual int64_t alloc_blocks_dis(bool wait, int64_t num_blocks, int64_t hint,
         int64_t blk_off, ExtentList *block_list);  
   virtual void set_blocks_used_int(int64_t start_block, int64_t num_blocks);
   virtual void set_blocks_used(int64_t start_block, int64_t num_blocks);
@@ -461,7 +461,7 @@ public:
 
   int64_t alloc_blocks_int(bool wait, bool wrap,
                          int64_t num_blocks, int64_t *start_block);
-  int64_t alloc_blocks_dis_int(bool wait, int64_t num_blocks,
+  int64_t alloc_blocks_dis_int(bool wait, int64_t num_blocks, int64_t hint,
         int64_t blk_off, ExtentList *block_list);  
   void free_blocks_int(int64_t start_block, int64_t num_blocks);
 
@@ -501,7 +501,7 @@ private:
   bool check_input_dis(int64_t num_blocks);
   void init_check(int64_t total_blocks, int64_t zone_size_block,
                  bmap_alloc_mode_t mode, bool def, bool stats_on);
-  int64_t alloc_blocks_dis_work(int64_t num_blocks, ExtentList *block_list, bool reserved);
+  int64_t alloc_blocks_dis_work(int64_t num_blocks, int64_t hint, ExtentList *block_list, bool reserved);
 
 public:
 
@@ -520,8 +520,8 @@ public:
   void set_blocks_used(int64_t start_block, int64_t num_blocks);
   void unreserve_blocks(int64_t blocks);
 
-  int64_t alloc_blocks_dis(int64_t num_blocks, ExtentList *block_list);
-  int64_t alloc_blocks_dis_res(int64_t num_blocks, ExtentList *block_list);
+  int64_t alloc_blocks_dis(int64_t num_blocks, int64_t hint, ExtentList *block_list);
+  int64_t alloc_blocks_dis_res(int64_t num_blocks, int64_t hint, ExtentList *block_list);
 
   void free_blocks_dis(int64_t num_blocks, ExtentList *block_list);
   bool is_allocated_dis(ExtentList *blocks, int64_t num_blocks);
index 402a07dff59403aa60bef76961162ee2c5843f33..b5b0f3b49025ec1d427cfcee7bb2e7ab8f2b0e01 100644 (file)
@@ -220,7 +220,7 @@ int BitMapAllocator::alloc_extents_dis(
   int64_t num = 0;
   *count = 0;
 
-  num = m_bit_alloc->alloc_blocks_dis_res(nblks, &block_list);
+  num = m_bit_alloc->alloc_blocks_dis_res(nblks, hint, &block_list);
   if (num < nblks) {
     m_bit_alloc->free_blocks_dis(num, &block_list);
     return -ENOSPC;