From 4c03cfd99eb9144e92740345d6874d1f07831b00 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Sun, 26 Aug 2018 08:55:05 -0400 Subject: [PATCH] mds: cleanup some asok commands Signed-off-by: Rishabh Dave Signed-off-by: Venky Shankar --- src/mds/MDCache.cc | 3 +-- src/mds/MDCache.h | 2 +- src/mds/MDSRank.cc | 19 +++++++------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index ed822ce77db..b46fbf1ba00 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -12025,7 +12025,7 @@ void MDCache::show_cache() show_func(p.second); } -int MDCache::cache_status(Formatter *f) +void MDCache::cache_status(Formatter *f) { f->open_object_section("cache"); @@ -12034,7 +12034,6 @@ int MDCache::cache_status(Formatter *f) f->close_section(); f->close_section(); - return 0; } void MDCache::dump_tree(CInode *in, const int cur_depth, const int max_depth, Formatter *f) diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index d16ecc48aba..1bbefffdcb4 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -1207,7 +1207,7 @@ public: int dump_cache(Formatter *f); void dump_tree(CInode *in, const int cur_depth, const int max_depth, Formatter *f); - int cache_status(Formatter *f); + void cache_status(Formatter *f); void dump_resolve_status(Formatter *f) const; void dump_rejoin_status(Formatter *f) const; diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index a365ed8223a..12897b9056f 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -2091,10 +2091,7 @@ bool MDSRankDispatcher::handle_asok_command(std::string_view command, } } else if (command == "cache status") { Mutex::Locker l(mds_lock); - int r = mdcache->cache_status(f); - if (r != 0) { - ss << "Failed to get cache status: " << cpp_strerror(r); - } + mdcache->cache_status(f); } else if (command == "dump tree") { command_dump_tree(cmdmap, ss, f); } else if (command == "dump loads") { @@ -3038,10 +3035,9 @@ bool MDSRankDispatcher::handle_command( return true; } - Formatter *f = new JSONFormatter(true); - dump_sessions(filter, f); - f->flush(*ds); - delete f; + JSONFormatter f(true); + dump_sessions(filter, &f); + f.flush(*ds); return true; } else if (prefix == "session evict" || prefix == "client evict") { std::vector filter_args; @@ -3058,10 +3054,9 @@ bool MDSRankDispatcher::handle_command( *need_reply = false; return true; } else if (prefix == "damage ls") { - Formatter *f = new JSONFormatter(true); - damage_table.dump(f); - f->flush(*ds); - delete f; + JSONFormatter f(true); + damage_table.dump(&f); + f.flush(*ds); return true; } else if (prefix == "damage rm") { damage_entry_id_t id = 0;