From: Patrick Donnelly Date: Tue, 9 Jan 2024 18:55:48 +0000 (-0500) Subject: mds: add command to get specific op X-Git-Tag: testing/wip-batrick-testing-20240411.154038~154^2~37 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3197a975a521654500173175c6e856c54df497ef;p=ceph-ci.git mds: add command to get specific op Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 850e9e700c4..3f29e756b4d 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -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"); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 8ab77f23a66..b51148eedcb 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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 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(&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)) { diff --git a/src/mds/Mutation.h b/src/mds/Mutation.h index 6e51275fbc1..ded6271f99e 100644 --- a/src/mds/Mutation.h +++ b/src/mds/Mutation.h @@ -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;