]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMap: fix stored_raw calculation
authorSage Weil <sage@redhat.com>
Wed, 24 Jul 2019 14:43:59 +0000 (09:43 -0500)
committerSage Weil <sage@redhat.com>
Tue, 6 Aug 2019 14:24:14 +0000 (09:24 -0500)
The get_user_bytes() helper is a bit weird because it uses the
raw_used_rate (replication/EC factor) so that it can work *backwards*
from raw usage to normalized user usage.  However, the legacy case that
works from PG stats does not use this factor... and the stored_raw value
(in the JSON output only) was incorrectly passing in a factor of 1.0,
which meant that for legacy mode it was a bogus value.

Fix by calculating stored_raw as stored_normalized * raw_used_rate.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/PGMap.cc
src/osd/osd_types.h

index 76404a965388e0157e2f39fd92fa15d0b96478a8..1e580541bccda4fb47e86ef83c1ce490e1d08c71 100644 (file)
@@ -916,6 +916,8 @@ void PGMapDigest::dump_object_stat_sum(
   // an approximation for actually stored user data
   auto stored_normalized = pool_stat.get_user_bytes(raw_used_rate, per_pool,
                                                    per_pool_omap);
+  // same, amplied by replication or EC
+  auto stored_raw = stored_normalized * raw_used_rate;
   if (f) {
     f->dump_int("stored", stored_normalized);
     f->dump_int("objects", sum.num_objects);
@@ -934,8 +936,7 @@ void PGMapDigest::dump_object_stat_sum(
       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", pool_stat.get_user_bytes(1.0, per_pool,
-                                                        per_pool_omap));
+      f->dump_int("stored_raw", stored_raw);
     }
   } else {
     tbl << stringify(byte_u_t(stored_normalized));
index e7c50752fb8df62cd2a72feb3bfaa830f22c3055..598b1478e612e52135d14bd0ef00c8e4ed80f2c1 100644 (file)
@@ -2530,15 +2530,19 @@ struct pool_stat_t {
     }
     return allocated_bytes;
   }
-  uint64_t get_user_bytes(float raw_used_rate, bool per_pool,
+  uint64_t get_user_bytes(float raw_used_rate, ///< space amp factor
+                         bool per_pool,
                          bool per_pool_omap) const {
+    // NOTE: we need the space amp factor so that we can work backwards from
+    // the raw utilization to the amount of data that the user actually stored.
     uint64_t user_bytes;
     if (per_pool) {
       user_bytes = raw_used_rate ? store_stats.data_stored / raw_used_rate : 0;
     } else {
-      // legacy mode, use numbers from 'stats'
-      user_bytes = stats.sum.num_bytes +
-       stats.sum.num_bytes_hit_set_archive;
+      // legacy mode, use numbers from 'stats'.  note that we do NOT use the
+      // raw_used_rate factor here because we are working from the PG stats
+      // directly.
+      user_bytes = stats.sum.num_bytes + stats.sum.num_bytes_hit_set_archive;
     }
     if (per_pool_omap) {
       user_bytes += store_stats.omap_allocated;