diff --git a/src/common/AsyncReserver.h b/src/common/AsyncReserver.h index fa49cfab8b42d..467e2570460be 100644 --- a/src/common/AsyncReserver.h +++ b/src/common/AsyncReserver.h @@ -21,6 +21,7 @@ #include "common/Mutex.h" #include "common/Finisher.h" +#include "common/Formatter.h" /** * Manages a configurable number of asyncronous reservations. @@ -79,6 +80,33 @@ class AsyncReserver { do_queues(); } + void dump(Formatter *f) { + Mutex::Locker l(lock); + f->dump_unsigned("max_allowed", max_allowed); + f->dump_unsigned("min_priority", min_priority); + f->open_array_section("queues"); + for (typename map > > ::const_iterator p = + queues.begin(); p != queues.end(); ++p) { + f->open_object_section("queue"); + f->dump_unsigned("priority", p->first); + f->open_array_section("items"); + for (typename list >::const_iterator q = + p->second.begin(); q != p->second.end(); ++q) { + f->dump_stream("item") << q->first; + } + f->close_section(); + f->close_section(); + } + f->close_section(); + f->open_array_section("in_progress"); + for (typename set::const_iterator p = in_progress.begin(); + p != in_progress.end(); + ++p) { + f->dump_stream("item") << *p; + } + f->close_section(); + } + /** * Requests a reservation * diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 363ba9c6e6396..41c3bbe3957fd 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1119,6 +1119,15 @@ bool OSD::asok_command(string command, cmdmap_t& cmdmap, string format, } f->close_section(); //watches + } else if (command == "dump_reservations") { + f->open_object_section("reservations"); + f->open_object_section("local_reservations"); + service.local_reserver.dump(f); + f->close_section(); + f->open_object_section("remote_reservations"); + service.remote_reserver.dump(f); + f->close_section(); + f->close_section(); } else { assert(0 == "broken asok registration"); } @@ -1375,6 +1384,10 @@ void OSD::final_init() "show clients which have active watches," " and on which objects"); assert(r == 0); + r = admin_socket->register_command("dump_reservations", "dump_reservations", + asok_hook, + "show recovery reservations"); + assert(r == 0); test_ops_hook = new TestOpsSocketHook(&(this->service), this->store); // Note: pools are CephString instead of CephPoolname because @@ -1656,6 +1669,7 @@ int OSD::shutdown() cct->get_admin_socket()->unregister_command("dump_op_pq_state"); cct->get_admin_socket()->unregister_command("dump_blacklist"); cct->get_admin_socket()->unregister_command("dump_watchers"); + cct->get_admin_socket()->unregister_command("dump_reservations"); delete asok_hook; asok_hook = NULL;