For each rbd-wnbd mapping we set an admin socket hook that can
be used to retrieve IO stats.
Now that the same daemon is reused for multiple mappings, we need
to distinguish the images when receiving a "stats" request.
For this reason, we'll add the image identifier to "wnbd stats"
admin socket commands.
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
(cherry picked from commit
83d58ab307063b4a37f3a297af2b0e6ba27e84dc)
AdminSocketClient client = AdminSocketClient(cfg.admin_sock_path);
std::string output;
- std::string result = client.do_request("{\"prefix\":\"wnbd stats\"}",
- &output);
+ std::string cmd = "{\"prefix\":\"wnbd stats " + cfg.devpath + "\"}";
+ std::string result = client.do_request(cmd, &output);
if (!result.empty()) {
std::cerr << "Admin socket error: " << result << std::endl;
return -EINVAL;
return err;
}
+WnbdAdminHook::WnbdAdminHook(WnbdHandler *handler) : m_handler(handler)
+{
+ g_ceph_context->get_admin_socket()->register_command(
+ std::string("wnbd stats ") + m_handler->instance_name,
+ this, "get WNBD stats");
+}
+
int WnbdAdminHook::call (
std::string_view command, const cmdmap_t& cmdmap,
const bufferlist&,
std::ostream& errss,
bufferlist& out)
{
- if (command == "wnbd stats") {
+ if (command == "wnbd stats " + m_handler->instance_name) {
return m_handler->dump_stats(f);
}
return -ENOSYS;
WnbdHandler *m_handler;
public:
- explicit WnbdAdminHook(WnbdHandler *handler) :
- m_handler(handler) {
- g_ceph_context->get_admin_socket()->register_command(
- "wnbd stats", this, "get WNBD stats");
- }
+ explicit WnbdAdminHook(WnbdHandler *handler);
~WnbdAdminHook() override {
g_ceph_context->get_admin_socket()->unregister_commands(this);
}
void set_sense(uint8_t sense_key, uint8_t asc);
};
+ friend WnbdAdminHook;
friend std::ostream &operator<<(std::ostream &os, const IOContext &ctx);
void send_io_response(IOContext *ctx);