mirror of
https://github.com/ceph/ceph
synced 2025-03-25 11:48:05 +00:00
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 - <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>
This commit is contained in:
parent
922211851e
commit
f62329f9a4
@ -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<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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user