From 936e578bf972170e3f95a6d258f73c6e79dbb97a Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Mon, 10 Jan 2022 23:31:27 +0000 Subject: [PATCH] common: introduce instrumented_raw to buffer_instrumentation Its initial user will be a unit test for BlueStore's huge paged-backed reading. Signed-off-by: Radoslaw Zarzynski --- src/common/buffer_instrumentation.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/common/buffer_instrumentation.h b/src/common/buffer_instrumentation.h index 65c80532397..fa1e843073b 100644 --- a/src/common/buffer_instrumentation.h +++ b/src/common/buffer_instrumentation.h @@ -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 +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 + bool is_raw_marked() const { + return dynamic_cast*>(get_raw()) != nullptr; + } }; } // namespace ceph::buffer_instrumentation -- 2.39.5