`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>
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
{
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;
+ }
+}
#define dout_context ClassHandler::get_instance().cct
-static constexpr int dout_subsys = ceph_subsys_objclass;
-
void *cls_alloc(size_t size)
{
return malloc(size);
*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;
- }
-}
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)
}
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;
+ }
+}