]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add command to get specific op
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 9 Jan 2024 18:55:48 +0000 (13:55 -0500)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 20 Mar 2024 14:56:54 +0000 (10:56 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc
src/mds/Mutation.h

index 850e9e700c41b7988bbdc9281104356f8f5df11a..3f29e756b4d2332b91f816a665d9693149b50cf6 100644 (file)
@@ -270,6 +270,12 @@ void MDSDaemon::set_up_admin_socket()
                                     asok_hook,
                                     "kill op");
   ceph_assert(r == 0);
+  r = admin_socket->register_command("op get "
+                                    "name=flags,type=CephChoices,strings=locks,n=N,req=false "
+                                     "name=id,type=CephString,req=true",
+                                    asok_hook,
+                                    "get op");
+  ceph_assert(r == 0);
   r = admin_socket->register_command("dump_blocked_ops",
       asok_hook,
       "show the blocked ops currently in flight");
index 8ab77f23a66f95a625015459b3b28866807dec04..b51148eedcb70005e4760ebb4efa810b6ea1c69b 100644 (file)
@@ -2693,6 +2693,52 @@ void MDSRankDispatcher::handle_asok_command(
         *css << "op_tracker disabled; set mds_enable_op_tracker=true to enable";
       }
     }
+  } else if (command == "op get") {
+    vector<string> flags;
+    cmd_getval(cmdmap, "flags", flags);
+
+    std::string id;
+    if(!cmd_getval(cmdmap, "id", id)) {
+      *css << "malformed id";
+      r = -CEPHFS_EINVAL;
+      goto out;
+    }
+    metareqid_t mrid;
+    try {
+      mrid = metareqid_t(id);
+    } catch (const std::exception& e) {
+      *css << "malformed id: " << e.what();
+      r = -CEPHFS_EINVAL;
+      goto out;
+    }
+
+    auto dumper = OpTracker::default_dumper;
+    if (flags.size()) {
+      if (flags.size()) {
+        /* use std::function if we actually want to capture flags someday */
+        dumper = [](const TrackedOp& op, Formatter* f) {
+          auto* req = dynamic_cast<const MDRequestImpl*>(&op);
+          if (req) {
+            req->dump_with_mds_lock(f);
+          } else {
+            op.dump_type(f);
+          }
+        };
+      }
+    }
+
+    std::lock_guard l(mds_lock);
+    if (!mdcache->have_request(mrid)) {
+      *css << "request does not exist";
+      r = -CEPHFS_ENOENT;
+      goto out;
+    }
+    auto mdr = mdcache->request_get(mrid);
+
+    f->open_object_section("op");
+    mdr->dump(ceph_clock_now(), f, dumper);
+    f->close_section();
+    r = 0;
   } else if (command == "op kill") {
     std::string id;
     if(!cmd_getval(cmdmap, "id", id)) {
index 6e51275fbc157843901a3898129d4494f823d900..ded6271f99ee3920ce14d8b1b42c9f2070584bbf 100644 (file)
@@ -238,6 +238,7 @@ public:
   virtual void dump(ceph::Formatter *f) const {
     _dump(f);
   }
+  using TrackedOp::dump;
   void _dump_op_descriptor(std::ostream& stream) const override;
 
   metareqid_t reqid;