]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados,mon: improve ceph and rados df reports.
authorIgor Fedotov <ifedotov@suse.com>
Fri, 23 Feb 2018 10:03:54 +0000 (13:03 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Thu, 6 Dec 2018 15:54:21 +0000 (18:54 +0300)
Fixes: https://tracker.ceph.com/issues/22159
Fixes: https://tracker.ceph.com/issues/20870
This adds  more parameters to estimate allocation granularity overhead and compression
effectiveness. RAW_USED column has been removed. USED column reflects
amount of space allocated for a pool at all replicas. Including
allocaction granularity overhead and taking ompression savings and
object content gaps into account.

Following columns were appended:
* STORED - approximation of bytes users've actually stored in a
pool, i.e netto data amount without compression, allocation and
other overheads (not applicable for 'rados df').
* USED COMPR - amount of bytes allocated to store compressed data, i.e.
compressed data plus allocation/replication overhead.
* UNDER COMPR - amount of data(icluding repicated one) passed through
compression and stored in that form.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/include/rados/librados.h
src/librados/librados_c.cc
src/librados/librados_cxx.cc
src/messages/MPGStats.h
src/mon/PGMap.cc
src/tools/rados/rados.cc

index 65377530be0b61ec42bf8637bfba4324bfe44d46..8ba19d6fccebb02a51c4348ee9a85036f103a735 100644 (file)
@@ -311,6 +311,14 @@ struct rados_pool_stat_t {
   uint64_t num_wr;
   /// objects written in KB
   uint64_t num_wr_kb;
+  ///< bytes originally provided by user
+  uint64_t num_user_bytes;
+  ///< bytes passed compression
+  uint64_t compressed_bytes_orig;
+  ///< bytes resulted after compression
+  uint64_t compressed_bytes;
+  ///< bytes allocated at storage
+  uint64_t compressed_bytes_alloc;
 };
 
 /**
index 0494c9baa5baf9de35edf1f775bb70d22c7e05aa..495f95ca25f077c90a393e90b6d1d90dc7203e8c 100644 (file)
@@ -962,8 +962,14 @@ extern "C" int rados_ioctx_pool_stat(rados_ioctx_t io, struct rados_pool_stat_t
   }
 
   ::pool_stat_t& r = rawresult[pool_name];
-  stats->num_kb = shift_round_up(r.stats.sum.num_bytes, 10);
-  stats->num_bytes = r.stats.sum.num_bytes;
+  uint64_t allocated_bytes = r.get_allocated_bytes();
+  // again, raw_used_rate is unknown hence using num_store_stats that
+  // will produce results similar to get_allocated_bytes(1.0) for legacy mode
+  // and stored / num_store_stats for the new collection mode
+  uint64_t user_bytes = r.get_user_bytes(r.num_store_stats);
+
+  stats->num_kb = shift_round_up(allocated_bytes, 10);
+  stats->num_bytes = allocated_bytes;
   stats->num_objects = r.stats.sum.num_objects;
   stats->num_object_clones = r.stats.sum.num_object_clones;
   stats->num_object_copies = r.stats.sum.num_object_copies;
@@ -976,6 +982,11 @@ extern "C" int rados_ioctx_pool_stat(rados_ioctx_t io, struct rados_pool_stat_t
   stats->num_rd_kb = r.stats.sum.num_rd_kb;
   stats->num_wr = r.stats.sum.num_wr;
   stats->num_wr_kb = r.stats.sum.num_wr_kb;
+  stats->num_user_bytes = user_bytes;
+  stats->compressed_bytes_orig = r.store_stats.data_compressed_original;
+  stats->compressed_bytes = r.store_stats.data_compressed;
+  stats->compressed_bytes_alloc = r.store_stats.data_compressed_allocated;
+
   tracepoint(librados, rados_ioctx_pool_stat_exit, 0, stats);
   return 0;
 }
index 41d6102e2657e29d572aa3bedd1a9432386ccb08..43fdac13515a5aff24e615adf3c9145ee8f55122 100644 (file)
@@ -2480,9 +2480,17 @@ int librados::Rados::get_pool_stats(std::list<string>& v,
        p != rawresult.end();
        ++p) {
     pool_stat_t& pv = result[p->first];
+    auto& pstat = p->second;
+    store_statfs_t &statfs = pstat.store_stats;
+    uint64_t allocated_bytes = pstat.get_allocated_bytes();
+    // again, raw_used_rate is unknown hence using num_store_stats that
+    // will produce results similar to get_allocated_bytes() for legacy mode
+    // and stored / num_store_stats for the new collection mode
+    uint64_t user_bytes = pstat.get_user_bytes(pstat.num_store_stats);
+
     object_stat_sum_t *sum = &p->second.stats.sum;
-    pv.num_kb = shift_round_up(sum->num_bytes, 10);
-    pv.num_bytes = sum->num_bytes;
+    pv.num_kb = shift_round_up(allocated_bytes, 10);
+    pv.num_bytes = allocated_bytes;
     pv.num_objects = sum->num_objects;
     pv.num_object_clones = sum->num_object_clones;
     pv.num_object_copies = sum->num_object_copies;
@@ -2493,6 +2501,10 @@ int librados::Rados::get_pool_stats(std::list<string>& v,
     pv.num_rd_kb = sum->num_rd_kb;
     pv.num_wr = sum->num_wr;
     pv.num_wr_kb = sum->num_wr_kb;
+    pv.num_user_bytes = user_bytes;
+    pv.compressed_bytes_orig = statfs.data_compressed_original;
+    pv.compressed_bytes = statfs.data_compressed;
+    pv.compressed_bytes_alloc = statfs.data_compressed_allocated;
   }
   return r;
 }
index 341d42d45fd5ae73c4db038bbe13c48201c668a6..491da1a96b5040025a9ab31c574eac4c4571ac70 100644 (file)
@@ -19,8 +19,8 @@
 #include "messages/PaxosServiceMessage.h"
 
 class MPGStats : public MessageInstance<MPGStats, PaxosServiceMessage> {
-  static const int HEAD_VERSION = 2;
-  static const int COMPAT_VERSION = 1;
+  static constexpr int HEAD_VERSION = 2;
+  static constexpr int COMPAT_VERSION = 1;
 public:
   friend factory;
 
index d6bade33066b3fcfd239d2bb960e34a494c868f0..bd15dc13076eb3c88b17be3d45c28afdbf3ad103 100644 (file)
@@ -805,7 +805,6 @@ void PGMapDigest::dump_pool_stats_full(
     } else {
       avail = avail_by_rule[ruleno];
     }
-
     if (f) {
       f->open_object_section("pool");
       f->dump_string("name", pool_name);
@@ -902,21 +901,23 @@ void PGMapDigest::dump_object_stat_sum(
     raw_used_rate *= (float)(sum.num_object_copies - sum.num_objects_degraded) / sum.num_object_copies;
   }
     
+  uint64_t used_bytes = pool_stat.get_allocated_bytes();
+
   float used = 0.0;
   // note avail passed in is raw_avail, calc raw_used here.
   if (avail) {
-    used = statfs.allocated;
+    used = used_bytes;
     used /= used + avail;
-  } else if (statfs.allocated) {
+  } else if (used_bytes) {
     used = 1.0;
   }
   auto avail_res = raw_used_rate ? avail / raw_used_rate : 0;
   // an approximation for actually stored user data
   auto stored_normalized =
-    raw_used_rate ? statfs.stored / raw_used_rate : 0;
+    raw_used_rate ? statfs.data_stored / raw_used_rate : 0;
   if (f) {
-    f->dump_int("kb_used", shift_round_up(statfs.allocated, 10));
-    f->dump_int("bytes_used", statfs.allocated);
+    f->dump_int("kb_used", shift_round_up(used_bytes, 10));
+    f->dump_int("bytes_used", used_bytes);
     f->dump_float("percent_used", used);
     f->dump_unsigned("max_avail", avail_res);
     f->dump_int("objects", sum.num_objects);
@@ -929,10 +930,10 @@ void PGMapDigest::dump_object_stat_sum(
       f->dump_int("wr", sum.num_wr);
       f->dump_int("wr_bytes", sum.num_wr_kb * 1024ull);
       f->dump_int("stored", stored_normalized);
-      f->dump_int("compress_bytes_used", statfs.compressed_allocated);
-      f->dump_int("compress_under_bytes", statfs.compressed_original);
+      f->dump_int("compress_bytes_used", statfs.data_compressed_allocated);
+      f->dump_int("compress_under_bytes", statfs.data_compressed_original);
       // Stored by user amplified by replication
-      f->dump_int("stored_raw", statfs.stored);
+      f->dump_int("stored_raw", statfs.data_stored);
     }
   } else {
     tbl << stringify(byte_u_t(statfs.allocated));
@@ -944,8 +945,8 @@ void PGMapDigest::dump_object_stat_sum(
           << stringify(byte_u_t(sum.num_rd))
           << stringify(byte_u_t(sum.num_wr))
          << stringify(byte_u_t(stored_normalized))
-         << stringify(byte_u_t(statfs.compressed_allocated))
-         << stringify(byte_u_t(statfs.compressed_original))
+         << stringify(byte_u_t(statfs.data_compressed_allocated))
+         << stringify(byte_u_t(statfs.data_compressed_original))
          ;
     }
   }
index 9f0a8024ed8dd5f5452bd3cc22ac4113b05d0ff5..de88f8ebfab896c0547bcbdf0a05ea6634a4645a 100644 (file)
@@ -2292,6 +2292,8 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       tab.define_column("RD", TextTable::RIGHT, TextTable::RIGHT);
       tab.define_column("WR_OPS", TextTable::RIGHT, TextTable::RIGHT);
       tab.define_column("WR", TextTable::RIGHT, TextTable::RIGHT);
+      tab.define_column("USED COMPR", TextTable::RIGHT, TextTable::RIGHT);
+      tab.define_column("UNDER COMPR", TextTable::RIGHT, TextTable::RIGHT);
     } else {
       formatter->open_object_section("stats");
       formatter->open_array_section("pools");
@@ -2314,6 +2316,8 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
             << byte_u_t(s.num_rd_kb << 10)
             << s.num_wr
             << byte_u_t(s.num_wr_kb << 10)
+           << byte_u_t(s.compressed_bytes_alloc)
+           << byte_u_t(s.compressed_bytes_orig)
             << TextTable::endrow;
       } else {
         formatter->open_object_section("pool");
@@ -2336,6 +2340,8 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
        formatter->dump_int("read_bytes", s.num_rd_kb * 1024ull);
        formatter->dump_int("write_ops", s.num_wr);
        formatter->dump_int("write_bytes", s.num_wr_kb * 1024ull);
+       formatter->dump_int("compress_bytes_used", s.compressed_bytes_alloc);
+       formatter->dump_int("compress_under_bytes", s.compressed_bytes_orig);
        formatter->close_section();
       }
     }