]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mempool: dump total, too 15352/head
authorSage Weil <sage@redhat.com>
Tue, 30 May 2017 18:47:04 +0000 (14:47 -0400)
committerSage Weil <sage@redhat.com>
Wed, 31 May 2017 18:48:00 +0000 (14:48 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/mempool.cc
src/include/mempool.h

index ccb74dd1ea0a9900f58bb96461999f69ba72120c..b6666d6b41b655b49008663c7c6e5a5fb00e0630 100644 (file)
@@ -41,12 +41,14 @@ const char *mempool::get_pool_name(mempool::pool_index_t ix) {
 
 void mempool::dump(ceph::Formatter *f)
 {
+  stats_t total;
   for (size_t i = 0; i < num_pools; ++i) {
     const pool_t &pool = mempool::get_pool((pool_index_t)i);
     f->open_object_section(get_pool_name((pool_index_t)i));
-    pool.dump(f);
+    pool.dump(f, &total);
     f->close_section();
   }
+  f->dump_object("total", total);
 }
 
 void mempool::set_debug_mode(bool d)
@@ -103,11 +105,14 @@ void mempool::pool_t::get_stats(
   }
 }
 
-void mempool::pool_t::dump(ceph::Formatter *f) const
+void mempool::pool_t::dump(ceph::Formatter *f, stats_t *ptotal) const
 {
   stats_t total;
   std::map<std::string, stats_t> by_type;
   get_stats(&total, &by_type);
+  if (ptotal) {
+    *ptotal += total;
+  }
   f->dump_object("total", total);
   if (!by_type.empty()) {
     for (auto &i : by_type) {
index f7aecece5924c076ab2333f5c2a11b13463904c1..a79fc824f426a37ef1e92d06e566237b0da81d1f 100644 (file)
@@ -190,6 +190,12 @@ struct stats_t {
     f->dump_int("items", items);
     f->dump_int("bytes", bytes);
   }
+
+  stats_t& operator+=(const stats_t& o) {
+    items += o.items;
+    bytes += o.bytes;
+    return *this;
+  }
 };
 
 pool_t& get_pool(pool_index_t ix);
@@ -246,7 +252,7 @@ public:
   void get_stats(stats_t *total,
                 std::map<std::string, stats_t> *by_type) const;
 
-  void dump(ceph::Formatter *f) const;
+  void dump(ceph::Formatter *f, stats_t *ptotal=0) const;
 };
 
 void dump(ceph::Formatter *f);