]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-wnbd: adjust admin socket hook to accept image path
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 26 Sep 2023 08:00:19 +0000 (08:00 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Sat, 2 Mar 2024 19:04:26 +0000 (19:04 +0000)
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)

src/tools/rbd_wnbd/rbd_wnbd.cc
src/tools/rbd_wnbd/wnbd_handler.cc
src/tools/rbd_wnbd/wnbd_handler.h

index b3a42285b2c1886b11de8b5d961c97a434a0261d..57691bb723600ca741f125eb25d0767f193a8892 100644 (file)
@@ -1159,8 +1159,8 @@ static int do_stats(std::string search_devpath)
 
     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;
index d5f4356ad1778ddaa3d5a596a76673c73c67daf8..d6597e32c4496d9aab8e9890069a869ef1184120 100644 (file)
@@ -65,6 +65,13 @@ int WnbdHandler::wait()
   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&,
@@ -72,7 +79,7 @@ int WnbdAdminHook::call (
   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;
index f3b3e4341b01a51015c0f2ce19cb82ab98660338..6b9886a6e38de64411144692d314a652ba0900d0 100644 (file)
@@ -44,11 +44,7 @@ class WnbdAdminHook : public AdminSocketHook {
   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);
   }
@@ -140,6 +136,7 @@ private:
     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);