From a35f00ae024439aaed244c0fd3654af4a0dabf11 Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Wed, 16 Apr 2025 06:36:15 +0000 Subject: [PATCH] os/bluestore: New unit test for BlueFS This cherry-pick only 'tracepoint' feature. Signed-off-by: Adam Kupczyk (parial cherry picked from commit a090f14fc7341a76bbbb35b3dab1b65c2e1c9041) --- src/os/bluestore/BlueFS.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index b7353348daec0..af66d9fdcbe9d 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -216,6 +216,35 @@ struct bluefs_shared_alloc_context_t { } }; +/* + Class debug_point is a helper intended for inserting debug tracepoints + in a least intrusive way. + The intention is to minimize both visual and code footprints. + + In code, it should look like: + debug_async_compact(1); + + Which should translate to: + if (debug_async_compact) debug_async_compact(1); + + And in release builds be eliminated completely. +*/ +template +class debug_point_t { +public: + debug_point_t() : m_func(nullptr) {}; + debug_point_t(T&& func) + : m_func(func) {} + template + void operator()(Arg... arg) { if (m_func) m_func(std::forward(arg...)); } + void operator=(T&& func) { m_func = std::move(func);} + void operator=(T& func) { m_func = func;} +private: + T m_func; +}; + + + class BlueFS { public: CephContext* cct; -- 2.39.5