mon: mgr: enable "osd df" on the manager

Fixes: http://tracker.ceph.com/issues/20256

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
This commit is contained in:
Greg Farnum 2017-06-13 14:37:54 -07:00
parent 234783c12b
commit 19810df09e
4 changed files with 26 additions and 2 deletions

View File

@ -23,7 +23,7 @@
#define dout_prefix *_dout << "mgr " << __func__ << " "
ClusterState::ClusterState(MonClient *monc_, Objecter *objecter_)
: monc(monc_), objecter(objecter_), lock("ClusterState")
: monc(monc_), objecter(objecter_), lock("ClusterState"), pgservice(pg_map)
{}
void ClusterState::set_objecter(Objecter *objecter_)

View File

@ -42,6 +42,8 @@ protected:
PGMap pg_map;
PGMap::Incremental pending_inc;
PGMapStatService pgservice;
bufferlist health_json;
bufferlist mon_status_json;
@ -82,6 +84,14 @@ public:
return std::forward<Callback>(cb)(pg_map, std::forward<Args>(args)...);
}
template<typename Callback, typename...Args>
auto with_pgservice(Callback&& cb, Args&&...args) const ->
decltype(cb(pgservice, std::forward<Args>(args)...))
{
Mutex::Locker l(lock);
return std::forward<Callback>(cb)(pg_map, std::forward<Args>(args)...);
}
template<typename... Args>
void with_monmap(Args &&... args) const
{

View File

@ -778,6 +778,20 @@ bool DaemonServer::handle_command(MCommand *m)
&on_finish->from_mon, &on_finish->outs, on_finish);
return true;
}
} else if (prefix == "osd df") {
string method;
cmd_getval(g_ceph_context, cmdctx->cmdmap, "output_method", method);
r = cluster_state.with_pgservice([&](const PGMapStatService& pgservice) {
return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
print_osd_utilization(osdmap, &pgservice, ss,
f.get(), method == "tree");
cmdctx->odata.append(ss);
return 0;
});
});
cmdctx->reply(r, "");
return true;
} else {
r = cluster_state.with_pgmap([&](const PGMap& pg_map) {
return cluster_state.with_osdmap([&](const OSDMap& osdmap) {

View File

@ -3927,7 +3927,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
string method;
cmd_getval(g_ceph_context, cmdmap, "output_method", method);
print_osd_utilization(osdmap, mon->pgservice, ds,
f ? f.get() : NULL, method == "tree");
f.get(), method == "tree");
rdata.append(ds);
} else if (prefix == "osd getmaxosd") {
if (f) {