]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Bug-Fix: When restoring allocation from file use a temp allocator and only copy the...
authorGabriel BenHanokh <benhanokh@gmail.com>
Mon, 18 Oct 2021 11:38:16 +0000 (14:38 +0300)
committerGabriel BenHanokh <benhanokh@gmail.com>
Tue, 19 Oct 2021 09:48:07 +0000 (12:48 +0300)
Signed-off-by: Gabriel Benhanokh <gbenhano@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 4f59ebde508a581df7ea6760aa220072a87b731e..edd563ced55b49316d4b11134085f51d364cd115 100644 (file)
@@ -17365,7 +17365,7 @@ int calc_allocator_image_trailer_size()
 }
 
 //-----------------------------------------------------------------------------------
-int BlueStore::restore_allocator(Allocator* allocator, uint64_t *num, uint64_t *bytes)
+int BlueStore::__restore_allocator(Allocator* allocator, uint64_t *num, uint64_t *bytes)
 {
   utime_t start_time = ceph_clock_now();
   BlueFS::FileReader *p_temp_handle = nullptr;
@@ -17518,6 +17518,31 @@ int BlueStore::restore_allocator(Allocator* allocator, uint64_t *num, uint64_t *
   return 0;
 }
 
+//-----------------------------------------------------------------------------------
+int BlueStore::restore_allocator(Allocator* dest_allocator, uint64_t *num, uint64_t *bytes)
+{
+  utime_t    start = ceph_clock_now();
+  Allocator *temp_allocator = create_bitmap_allocator(bdev->get_size());
+  if (temp_allocator == nullptr) {
+    derr << "****failed create_bitmap_allocator()" << dendl;
+    return -1;
+  }
+
+  int ret = __restore_allocator(temp_allocator, num, bytes);
+  if (ret != 0) {
+    delete temp_allocator;
+    return ret;
+  }
+
+  uint64_t num_entries = 0;
+  dout(5) << " calling copy_allocator(bitmap_allocator -> shared_alloc.a)" << dendl;  
+  copy_allocator(temp_allocator, dest_allocator, &num_entries);
+  delete temp_allocator;
+  utime_t duration = ceph_clock_now() - start;
+  dout(5) << " <<<FINISH>>> in " << duration << " seconds, num_entries=" << num_entries << dendl;
+  return ret;
+}
+
 //-------------------------------------------------------------------------
 void BlueStore::ExtentMap::provide_shard_info_to_onode(bufferlist v, uint32_t shard_id)
 {
index 29ff87d5ff13ea2b18177154b04fc0595bb21448..31e1acfa2aa0533fec379c7c771ed165a6f0ffd3 100644 (file)
@@ -3547,6 +3547,7 @@ private:
   int  copy_allocator(Allocator* src_alloc, Allocator *dest_alloc, uint64_t* p_num_entries);
   int  store_allocator(Allocator* allocator);
   int  invalidate_allocation_file_on_bluefs();
+  int  __restore_allocator(Allocator* allocator, uint64_t *num, uint64_t *bytes);
   int  restore_allocator(Allocator* allocator, uint64_t *num, uint64_t *bytes);
   int  read_allocation_from_drive_on_startup();
   int  reconstruct_allocations(Allocator* allocator, read_alloc_stats_t &stats);