From f62329f9a400ea97f9f2fd0f8b94e63d0fdd7628 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 4 Mar 2022 11:03:05 +0000 Subject: [PATCH] crimson, cls: fix the inability to print logs from plugins. `cls_log()` of the interface between an OSD and a plugin (a Ceph Class) is implemented on top of the `dout` macros and shared between crimson and the classical OSD. Unfortunately, when a plugin is hosted inside crimson, this causes the inability to send to any in-plugin generated message to the `seastar::logger` for the `objclass` subsystem. This patch differtiates the implementation of `cls_log()`, and thus allow the `seastar::logger`-based implementation of `dout` to be used. After the fix: ``` DEBUG 2022-03-07 14:12:14,124 [shard 0] osd - handling op call on object 1:424638ea:::image1:head DEBUG 2022-03-07 14:12:14,124 [shard 0] osd - calling method rbd.create, num_read=0, num_write=0 DEBUG 2022-03-07 14:12:14,125 [shard 0] objclass - ../src/cls/rbd/cls_rbd.cc:787: create object_prefix=image1 size=0 order=22 features=0 DEBUG 2022-03-07 14:12:14,125 [shard 0] osd - handling op omap-get-vals-by-keys on object 1:424638ea:::image1:head DEBUG 2022-03-07 14:12:14,125 [shard 0] osd - omap_get_vals_by_keys: object does not exist: 1:424638ea:::image1:head ``` Signed-off-by: Radoslaw Zarzynski --- src/crimson/osd/objclass.cc | 24 ++++++++++++++++++++++++ src/objclass/class_api.cc | 20 -------------------- src/osd/objclass.cc | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/crimson/osd/objclass.cc b/src/crimson/osd/objclass.cc index f0f6d001d8fe4..c32f7eb508210 100644 --- a/src/crimson/osd/objclass.cc +++ b/src/crimson/osd/objclass.cc @@ -21,6 +21,10 @@ using std::map; using std::string; +#define dout_context ClassHandler::get_instance().cct + +static constexpr int dout_subsys = ceph_subsys_objclass; + static inline int execute_osd_op(cls_method_context_t hctx, OSDOp& op) { // we can expect the memory under `ret` will be still fine after @@ -527,3 +531,23 @@ int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map -1 && n < size) || size > MAX_SIZE) { + dout(ceph::dout::need_dynamic(level)) << buf << dendl; + return n; + } + size *= 2; + } +} diff --git a/src/objclass/class_api.cc b/src/objclass/class_api.cc index b50b6caf23f92..e649402a26461 100644 --- a/src/objclass/class_api.cc +++ b/src/objclass/class_api.cc @@ -15,8 +15,6 @@ #define dout_context ClassHandler::get_instance().cct -static constexpr int dout_subsys = ceph_subsys_objclass; - void *cls_alloc(size_t size) { return malloc(size); @@ -147,21 +145,3 @@ void cls_cxx_subop_version(cls_method_context_t hctx, std::string *s) *s = buf; } - -int cls_log(int level, const char *format, ...) -{ - int size = 256; - va_list ap; - while (1) { - char buf[size]; - va_start(ap, format); - int n = vsnprintf(buf, size, format, ap); - va_end(ap); -#define MAX_SIZE 8196 - if ((n > -1 && n < size) || size > MAX_SIZE) { - dout(ceph::dout::need_dynamic(level)) << buf << dendl; - return n; - } - size *= 2; - } -} diff --git a/src/osd/objclass.cc b/src/osd/objclass.cc index b447d45f38730..eb20811a233b3 100644 --- a/src/osd/objclass.cc +++ b/src/osd/objclass.cc @@ -27,6 +27,8 @@ using ceph::decode; using ceph::encode; using ceph::real_time; +static constexpr int dout_subsys = ceph_subsys_objclass; + int cls_call(cls_method_context_t hctx, const char *cls, const char *method, char *indata, int datalen, char **outdata, int *outdatalen) @@ -746,3 +748,23 @@ int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map -1 && n < size) || size > MAX_SIZE) { + dout(ceph::dout::need_dynamic(level)) << buf << dendl; + return n; + } + size *= 2; + } +} -- 2.39.5