From 7542a3582bb981440f00306c303a58d1b4d7e152 Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Sun, 1 Jan 2017 12:47:03 +0800 Subject: [PATCH] osd: add asock command to dump the scrub queue * add a public method to dumps scrubs * register new command "dump_scrubs" to asock_admin Fixes: http://tracker.ceph.com/issues/17861 Signed-off-by: liuchang0812 --- src/osd/OSD.cc | 14 ++++++++++++-- src/osd/OSD.h | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 70f39fde5b49..8ba5c5c778de 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1937,6 +1937,8 @@ bool OSD::asok_command(string command, cmdmap_t& cmdmap, string format, f->close_section(); } else if (command == "dump_objectstore_kv_stats") { store->get_db_statistics(f); + } else if (command == "dump_scrubs") { + service.dumps_scrub(f); } else { assert(0 == "broken asok registration"); } @@ -2395,8 +2397,16 @@ void OSD::final_init() "get malloc extension heap property"); assert(r == 0); - r = admin_socket->register_command("dump_objectstore_kv_stats", "dump_objectstore_kv_stats", asok_hook, - "print statistics of kvdb which used by bluestore"); + r = admin_socket->register_command("dump_objectstore_kv_stats", + "dump_objectstore_kv_stats", + asok_hook, + "print statistics of kvdb which used by bluestore"); + assert(r == 0); + + r = admin_socket->register_command("dump_scrubs", + "dump_scrubs", + asok_hook, + "print scheduled scrubs"); assert(r == 0); test_ops_hook = new TestOpsSocketHook(&(this->service), this->store); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index d404d0254e5c..3a4bb8a3b3d7 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -685,6 +685,22 @@ public: return true; } + void dumps_scrub(Formatter *f) { + assert(f != nullptr); + Mutex::Locker l(sched_scrub_lock); + + f->open_array_section("scrubs"); + for (const auto &i: sched_scrub_pg) { + f->open_object_section("scrub"); + f->dump_stream("pgid") << i.pgid; + f->dump_stream("sched_time") << i.sched_time; + f->dump_stream("deadline") << i.deadline; + f->dump_bool("forced", i.sched_time == i.deadline); + f->close_section(); + } + f->close_section(); + } + bool can_inc_scrubs_pending(); bool inc_scrubs_pending(); void inc_scrubs_active(bool reserved); -- 2.47.3