]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Add printout to CBT's recovery-compare command 64369/head
authorAdam Kupczyk <akupczyk@ibm.com>
Fri, 29 May 2026 11:16:39 +0000 (11:16 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Mon, 8 Jun 2026 17:04:29 +0000 (17:04 +0000)
1) recovery-compare prints on stdout
2) gracefully rejects comparing when multithreaded not enabled

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_tool.cc

index fde30a9499e2d19a3f9a196728db437f7d73037f..4629bc3b4c3912a7ae05a91dfd01151d953a6c59 100644 (file)
@@ -21168,7 +21168,7 @@ int BlueStore::read_allocation_from_drive_for_bluestore_tool()
   return ret;
 }
 
-int BlueStore::compare_allocation_recovery_for_bluestore_tool()
+int BlueStore::compare_allocation_recovery_for_bluestore_tool(ostream& out)
 {
   dout(5) << __func__ << dendl;
   int ret = 0;
@@ -21189,13 +21189,14 @@ int BlueStore::compare_allocation_recovery_for_bluestore_tool()
 
   SimpleBitmap old_bitmap(cct, (bdev->get_size()/ min_alloc_size));
   read_alloc_stats_t old_stats = {};
-  ret = allocation_recover_and_compare(&old_bitmap, old_stats);
+  ret = allocation_recover_and_compare(&old_bitmap, old_stats, &out);
   return ret;
 }
 
 int BlueStore::allocation_recover_and_compare(
   SimpleBitmap *sbmap,
-  read_alloc_stats_t &stats)
+  read_alloc_stats_t &stats,
+  ostream* extra_out)
 {
   int ret = 0;
   SimpleBitmap& old_bitmap = *sbmap;
@@ -21204,27 +21205,41 @@ int BlueStore::allocation_recover_and_compare(
   read_alloc_stats_t mt_stats = {};
   utime_t start;
   utime_t duration;
+  ostringstream out;
+  auto flushl = [&]() {
+    dout(0) << out.str() << dendl;
+    if (extra_out) {
+      (*extra_out) << out.str() << std::endl;
+      std::flush(*extra_out);
+    }
+    out.str("");
+  };
 
   if (cct->_conf.get_val<uint64_t>("bluestore_allocation_recovery_threads") != 0) {
-    dout(0) << "New recovery start" << dendl;
+    out << "New recovery start"; flushl();
     start = ceph_clock_now();
     ret = read_allocation_from_onodes_mt(&mt_bitmap, mt_stats);
     duration = ceph_clock_now() - start;
-    dout(0) << "New recovery result=" << ret << " took " << duration << " seconds" << dendl;
-    dout(0) << "New recovery stats=" << std::endl << mt_stats << dendl;
+    out << "New recovery result=" << ret << " took " << duration << " seconds"; flushl();
+    out << "New recovery stats=" << std::endl << mt_stats; flushl();
   }
 
-  dout(0) << "Legacy recovery start" << dendl;
+  out << "Legacy recovery start"; flushl();
   start = ceph_clock_now();
   ret = read_allocation_from_onodes(&old_bitmap, old_stats);
   duration = ceph_clock_now() - start;
-  dout(0) << "Legacy recovery result=" << ret << " took " << duration << " seconds" << dendl;
-  dout(0) << "Legacy recovery stats=" << std::endl << old_stats << dendl;
+  out << "Legacy recovery result=" << ret << " took " << duration << " seconds"; flushl();
+  out << "Legacy recovery stats=" << std::endl << old_stats; flushl();
 
-  if (old_stats.actual_pool_vstatfs == mt_stats.actual_pool_vstatfs)
-    dout(0) << "FSstats the same." << dendl;
-  else {
-    dout(0) << "FSTATS DIFFERENT !" << dendl;
+  if (cct->_conf.get_val<uint64_t>("bluestore_allocation_recovery_threads") == 0) {
+    out << "bluestore_allocation_recovery_threads = 0"; flushl();
+    out << "No multithread recovery to compare."; flushl();
+    return 0;
+  }
+  if (old_stats.actual_pool_vstatfs == mt_stats.actual_pool_vstatfs) {
+    out << "FSstats the same."; flushl();
+  } else {
+    out << "FSTATS DIFFERENT !"; flushl();
     ret = -1;
   }
 
@@ -21235,9 +21250,9 @@ int BlueStore::allocation_recover_and_compare(
     ext_a = mt_bitmap.get_next_set_extent(offset);
     ext_b = old_bitmap.get_next_set_extent(offset);
     if (ext_a != ext_b) {
-      dout(0) << "ALLOCATOR DIFFERENT !, first:" << dendl;
-      dout(0) << ext_a.offset << "~" << ext_a.length << dendl;
-      dout(0) << ext_b.offset << "~" << ext_b.length << dendl;
+      out << "ALLOCATOR DIFFERENT !, first:"; flushl();
+      out << ext_a.offset << "~" << ext_a.length; flushl();
+      out << ext_b.offset << "~" << ext_b.length; flushl();
       offset = 1;
       ret = -1;
       break;
@@ -21245,7 +21260,7 @@ int BlueStore::allocation_recover_and_compare(
     offset = ext_a.offset + ext_a.length;
   } while (offset != 0);
   if (offset == 0) {
-    dout(0) << "Allocators the same." << dendl;
+    out << "Allocators the same."; flushl();
   }
   return ret;
 }
index 9882949f11f823ac4d553ab6a1a574f8335388f5..f7fba91227b139adeea7e5698c82aff0802bde94 100644 (file)
@@ -4115,7 +4115,7 @@ public:
   int  push_allocation_to_rocksdb();
   int  read_allocation_from_drive_for_bluestore_tool();
 #endif
-  int compare_allocation_recovery_for_bluestore_tool();
+  int compare_allocation_recovery_for_bluestore_tool(std::ostream& out);
 
   void set_allocation_in_simple_bmap(SimpleBitmap* sbmap, uint64_t offset, uint64_t length);
 
@@ -4135,7 +4135,10 @@ private:
     std::map<uint64_t, volatile_statfs> actual_pool_vstatfs;
     volatile_statfs actual_store_vstatfs;
   };
-  int allocation_recover_and_compare(SimpleBitmap *sbmap, read_alloc_stats_t &stats);
+  int allocation_recover_and_compare(
+    SimpleBitmap *sbmap,
+    read_alloc_stats_t &stats,
+    std::ostream* extra_out = nullptr);
 
   class Decoder_AllocationsAndStatFS;
   class ExtentDecoderPartial : public ExtentMap::ExtentDecoder {
index e010f127aff69f050c5b8163309f09432278dd8b..74aab7ce72cf911a8f525fd543a651cc847c6463 100644 (file)
@@ -720,7 +720,7 @@ int main(int argc, char **argv)
     cout << action << " bluestore compare new and legacy onode recovery" << std::endl;
     validate_path(cct.get(), path, false);
     BlueStore bluestore(cct.get(), path);
-    int r = bluestore.compare_allocation_recovery_for_bluestore_tool();
+    int r = bluestore.compare_allocation_recovery_for_bluestore_tool(cout);
     if (r < 0) {
       cerr << action << " failed: " << cpp_strerror(r) << std::endl;
       exit(EXIT_FAILURE);