]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: introduce instrumented_raw to buffer_instrumentation
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 10 Jan 2022 23:31:27 +0000 (23:31 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 12 Jan 2022 20:35:50 +0000 (20:35 +0000)
Its initial user will be a unit test for BlueStore's huge
paged-backed reading.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/buffer_instrumentation.h

index 65c80532397685293d48e75fab18685379e524f1..fa1e843073bbb4a05527c059e52b233a950716b2 100644 (file)
@@ -2,13 +2,31 @@
 // vim: ts=8 sw=2 smarttab
 
 #include "include/buffer.h"
+#include "include/buffer_raw.h"
 
 namespace ceph::buffer_instrumentation {
 
+// this is nothing more than an intermediary for a class hierarchy which
+// can placed between a user's custom raw and the `ceph::buffer::raw` to
+// detect whether a given `ceph::buffer::ptr` instance wraps a particular
+// raw's implementation (via `dynamic_cast` or `typeid`).
+//
+// users are supposed to define marker type (e.g. `class my_marker{}`).
+// this marker. i
+template <class MarkerT>
+struct instrumented_raw : public ceph::buffer::raw {
+  using raw::raw;
+};
+
 struct instrumented_bptr : public ceph::buffer::ptr {
   const ceph::buffer::raw* get_raw() const {
     return _raw;
   }
+
+  template <class MarkerT>
+  bool is_raw_marked() const {
+    return dynamic_cast<const instrumented_raw<MarkerT>*>(get_raw()) != nullptr;
+  }
 };
 
 } // namespace ceph::buffer_instrumentation