Skip to content

Commit

Permalink
Merge pull request ceph#2059 from ceph/wip-osd-dumpres
Browse files Browse the repository at this point in the history
osd: allow dumping reservation state via asok

Reviewed-by: Samuel Just <[email protected]>
  • Loading branch information
Sage Weil committed Jul 3, 2014
2 parents 303a9fd + 70c0723 commit dc1e425
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/common/AsyncReserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "common/Mutex.h"
#include "common/Finisher.h"
#include "common/Formatter.h"

/**
* Manages a configurable number of asyncronous reservations.
Expand Down Expand Up @@ -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<unsigned, list<pair<T, Context*> > > ::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<pair<T, Context*> >::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<T>::const_iterator p = in_progress.begin();
p != in_progress.end();
++p) {
f->dump_stream("item") << *p;
}
f->close_section();
}

/**
* Requests a reservation
*
Expand Down
14 changes: 14 additions & 0 deletions src/osd/OSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit dc1e425

Please sign in to comment.