Skip to content

Commit 83d58ab

Browse files
rbd-wnbd: adjust admin socket hook to accept image path
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 <[email protected]>
1 parent 0d73d31 commit 83d58ab

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/tools/rbd_wnbd/rbd_wnbd.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,8 @@ static int do_stats(std::string search_devpath)
11591159

11601160
AdminSocketClient client = AdminSocketClient(cfg.admin_sock_path);
11611161
std::string output;
1162-
std::string result = client.do_request("{\"prefix\":\"wnbd stats\"}",
1163-
&output);
1162+
std::string cmd = "{\"prefix\":\"wnbd stats " + cfg.devpath + "\"}";
1163+
std::string result = client.do_request(cmd, &output);
11641164
if (!result.empty()) {
11651165
std::cerr << "Admin socket error: " << result << std::endl;
11661166
return -EINVAL;

src/tools/rbd_wnbd/wnbd_handler.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,21 @@ int WnbdHandler::wait()
6565
return err;
6666
}
6767

68+
WnbdAdminHook::WnbdAdminHook(WnbdHandler *handler) : m_handler(handler)
69+
{
70+
g_ceph_context->get_admin_socket()->register_command(
71+
std::string("wnbd stats ") + m_handler->instance_name,
72+
this, "get WNBD stats");
73+
}
74+
6875
int WnbdAdminHook::call (
6976
std::string_view command, const cmdmap_t& cmdmap,
7077
const bufferlist&,
7178
Formatter *f,
7279
std::ostream& errss,
7380
bufferlist& out)
7481
{
75-
if (command == "wnbd stats") {
82+
if (command == "wnbd stats " + m_handler->instance_name) {
7683
return m_handler->dump_stats(f);
7784
}
7885
return -ENOSYS;

src/tools/rbd_wnbd/wnbd_handler.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ class WnbdAdminHook : public AdminSocketHook {
4444
WnbdHandler *m_handler;
4545

4646
public:
47-
explicit WnbdAdminHook(WnbdHandler *handler) :
48-
m_handler(handler) {
49-
g_ceph_context->get_admin_socket()->register_command(
50-
"wnbd stats", this, "get WNBD stats");
51-
}
47+
explicit WnbdAdminHook(WnbdHandler *handler);
5248
~WnbdAdminHook() override {
5349
g_ceph_context->get_admin_socket()->unregister_commands(this);
5450
}
@@ -140,6 +136,7 @@ class WnbdHandler
140136
void set_sense(uint8_t sense_key, uint8_t asc);
141137
};
142138

139+
friend WnbdAdminHook;
143140
friend std::ostream &operator<<(std::ostream &os, const IOContext &ctx);
144141

145142
void send_io_response(IOContext *ctx);

0 commit comments

Comments
 (0)