From: John Spray Date: Fri, 17 Oct 2014 13:13:09 +0000 (+0100) Subject: client: add 'status' asok X-Git-Tag: v0.91~47^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a8babcbaa90511e27603423bd8310ae472f69205;p=ceph.git client: add 'status' asok Useful in test/debug for querying OSD epoch and OSD barrier epoch. Signed-off-by: John Spray --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 7951d0188f1f..d39ed805e0f6 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -129,6 +129,8 @@ bool Client::CommandHook::call(std::string command, cmdmap_t& cmdmap, m_client->dump_cache(f); else if (command == "kick_stale_sessions") m_client->_kick_stale_sessions(); + else if (command == "status") + m_client->dump_status(f); else assert(0 == "bad command registered"); m_client->client_lock.Unlock(); @@ -350,6 +352,35 @@ void Client::dump_cache(Formatter *f) f->close_section(); } +void Client::dump_status(Formatter *f) +{ + assert(client_lock.is_locked_by_me()); + + ldout(cct, 1) << __func__ << dendl; + + const OSDMap *osdmap = objecter->get_osdmap_read(); + const epoch_t osd_epoch = osdmap->get_epoch(); + objecter->put_osdmap_read(); + + if (f) { + f->open_object_section("metadata"); + { + for (std::map::const_iterator i = metadata.begin(); + i != metadata.end(); ++i) { + f->dump_string(i->first.c_str(), i->second); + } + } + f->close_section(); + + f->dump_int("dentry_count", lru.lru_get_size()); + f->dump_int("dentry_pinned_count", lru.lru_get_num_pinned()); + f->dump_int("inode_count", inode_map.size()); + f->dump_int("mds_epoch", mdsmap->get_epoch()); + f->dump_int("osd_epoch", osd_epoch); + f->dump_int("osd_epoch_barrier", cap_epoch_barrier); + } +} + int Client::init() { client_lock.Lock(); @@ -426,6 +457,14 @@ int Client::init() lderr(cct) << "error registering admin socket command: " << cpp_strerror(-ret) << dendl; } + ret = admin_socket->register_command("status", + "status", + &m_command_hook, + "show overall client status"); + if (ret < 0) { + lderr(cct) << "error registering admin socket command: " + << cpp_strerror(-ret) << dendl; + } populate_metadata(); @@ -444,6 +483,7 @@ void Client::shutdown() admin_socket->unregister_command("mds_sessions"); admin_socket->unregister_command("dump_cache"); admin_socket->unregister_command("kick_stale_sessions"); + admin_socket->unregister_command("status"); if (ino_invalidate_cb) { ldout(cct, 10) << "shutdown stopping cache invalidator finisher" << dendl; diff --git a/src/client/Client.h b/src/client/Client.h index 0d9132ba247b..4e4b5a512ca3 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -440,6 +440,8 @@ protected: // force read-only void force_session_readonly(MetaSession *s); + void dump_status(Formatter *f); // debug + // trace generation ofstream traceout;