From 5ccce8d0236ebf89d7083fc202de0545e10f889f Mon Sep 17 00:00:00 2001 From: NitzanMordhai Date: Wed, 8 Jun 2022 13:41:13 +0000 Subject: [PATCH] osd: add option to dump pg log to pg command Currently we need to stop the cluster and use ceph_objectstore_tool to dump pg log with that commit we will be able to dump pg logs with PG command Signed-off-by: Nitzan Mordechai --- src/osd/OSD.cc | 13 +++++++++++++ src/osd/PrimaryLogPG.cc | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index ef55e440b06c1..03c6553395e90 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2527,6 +2527,7 @@ void OSD::asok_command( // --- PG commands are routed here to PG::do_command --- if (prefix == "pg" || prefix == "query" || + prefix == "log" || prefix == "mark_unfound_lost" || prefix == "list_unfound" || prefix == "scrub" || @@ -4188,6 +4189,13 @@ void OSD::final_init() asok_hook, ""); ceph_assert(r == 0); + r = admin_socket->register_command( + "pg " \ + "name=pgid,type=CephPgid " \ + "name=cmd,type=CephChoices,strings=log", + asok_hook, + ""); + ceph_assert(r == 0); r = admin_socket->register_command( "pg " \ "name=pgid,type=CephPgid " \ @@ -4226,6 +4234,11 @@ void OSD::final_init() asok_hook, "show details of a specific pg"); ceph_assert(r == 0); + r = admin_socket->register_command( + "log", + asok_hook, + "dump pg_log of a specific pg"); + ceph_assert(r == 0); r = admin_socket->register_command( "mark_unfound_lost " \ "name=pgid,type=CephPgid,req=false " \ diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 1b60dfc0793aa..b71c2eab80936 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -1038,7 +1038,14 @@ void PrimaryLogPG::do_command( f->close_section(); } - + else if (prefix == "log") { + + f->open_object_section("op_log"); + f->open_object_section("pg_log_t"); + recovery_state.get_pg_log().get_log().dump(f.get()); + f->close_section(); + f->close_section(); + } else if (prefix == "mark_unfound_lost") { string mulcmd; cmd_getval(cmdmap, "mulcmd", mulcmd); -- 2.39.5