]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson, cls: fix the inability to print logs from plugins.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 4 Mar 2022 11:03:05 +0000 (11:03 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 8 Mar 2022 01:31:10 +0000 (01:31 +0000)
`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 - <cls> ../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 <rzarzyns@redhat.com>
src/crimson/osd/objclass.cc
src/objclass/class_api.cc
src/osd/objclass.cc

index f0f6d001d8fe49b682e33dce4bb8fbd386029b86..c32f7eb5082104e7cb3dd645551c58a383fbae06 100644 (file)
 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<std::string, b
 {
   return 0;
 }
+
+// although at first glance the implementation looks the same as in
+// the classical OSD, it's different b/c of how the dout macro expands.
+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;
+   }
+}
index b50b6caf23f92c1948c0203920c5355c4390de11..e649402a26461554c20835824c5ea53641024580 100644 (file)
@@ -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;
-   }
-}
index b447d45f3873044f6aba939a7f8adc9743c20e3c..eb20811a233b36047568836fbb6331b5fa34ee3b 100644 (file)
@@ -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<std::string, b
   }
   return r;
 }
+
+// although at first glance the implementation looks the same as in
+// crimson-osd, it's different b/c of how the dout macro expands.
+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;
+   }
+}