]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Add debug hooks
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 14 Nov 2024 11:23:25 +0000 (11:23 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Wed, 18 Dec 2024 09:36:33 +0000 (09:36 +0000)
Added debug hooks for:
- init_alloc
- deferred start/stop/operation

This created framework for specific unit tests.
These functions are as name suggests debug level, only for unittests.

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

index a024a0c2105abf390d3ceceb20a7d6ea5b3d75da..c521ee8fbfc20ea44f55644ef1dd85a5c655c40e 100644 (file)
@@ -7260,7 +7260,7 @@ int BlueStore::_init_alloc()
           << ", free 0x" << alloc->get_free()
           << ", fragmentation " << alloc->get_fragmentation()
           << std::dec << dendl;
-
+  if (tracepoint_debug_init_alloc_done) tracepoint_debug_init_alloc_done();
   return 0;
 }
 
@@ -15276,6 +15276,7 @@ int BlueStore::_deferred_replay()
     fake_ch = true;
   }
   OpSequencer *osr = static_cast<OpSequencer*>(ch->osr.get());
+  if (tracepoint_debug_deferred_replay_start) tracepoint_debug_deferred_replay_start();
   KeyValueDB::Iterator it = db->get_iterator(PREFIX_DEFERRED);
   for (it->lower_bound(string()); it->valid(); it->next(), ++count) {
     dout(20) << __func__ << " replay " << pretty_binary_string(it->key())
@@ -15295,6 +15296,7 @@ int BlueStore::_deferred_replay()
     }
     bool has_some = _eliminate_outdated_deferred(deferred_txn, bluefs_extents);
     if (has_some) {
+      if (tracepoint_debug_deferred_replay_track) tracepoint_debug_deferred_replay_track(*deferred_txn);
       TransContext *txc = _txc_create(ch.get(), osr,  nullptr);
       txc->deferred_txn = deferred_txn;
       txc->set_state(TransContext::STATE_KV_DONE);
@@ -15307,6 +15309,7 @@ int BlueStore::_deferred_replay()
   dout(20) << __func__ << " draining osr" << dendl;
   _osr_register_zombie(osr);
   _osr_drain_all();
+  if (tracepoint_debug_deferred_replay_end) tracepoint_debug_deferred_replay_end();
   if (fake_ch) {
     new_coll_map.clear();
   }
index 99f8d057cf0a11b6891c32c6ae66380df8f84a38..12a9140ff7940222c213328bddc5be5ae53bd171 100644 (file)
@@ -3586,6 +3586,19 @@ public:
   void debug_set_prefer_deferred_size(uint64_t s) {
     prefer_deferred_size = s;
   }
+  void set_tracepoint_debug_deferred_replay_start(std::function<void()> action) {
+    tracepoint_debug_deferred_replay_start = action;
+  }
+  void set_tracepoint_debug_deferred_replay_end(std::function<void()> action) {
+    tracepoint_debug_deferred_replay_end = action;
+  }
+  void set_tracepoint_debug_deferred_replay_track(
+    std::function<void(const bluestore_deferred_transaction_t&)> action) {
+    tracepoint_debug_deferred_replay_track = action;
+  }
+  void set_tracepoint_debug_init_alloc_done(std::function<void()> action) {
+    tracepoint_debug_init_alloc_done = action;
+  }
   inline void log_latency(const char* name,
     int idx,
     const ceph::timespan& lat,
@@ -3601,6 +3614,11 @@ public:
     int idx2 = l_bluestore_first);
 
 private:
+  std::function<void()> tracepoint_debug_deferred_replay_start = nullptr;
+  std::function<void()> tracepoint_debug_deferred_replay_end = nullptr;
+  std::function<void(const bluestore_deferred_transaction_t&)>
+    tracepoint_debug_deferred_replay_track = nullptr;
+  std::function<void()> tracepoint_debug_init_alloc_done = nullptr;
   bool _debug_data_eio(const ghobject_t& o) {
     if (!cct->_conf->bluestore_debug_inject_read_err) {
       return false;