From 5a6ede0ec1d52f061db9e7e2425d905ce250c2e2 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 24 Jul 2019 09:43:59 -0500 Subject: [PATCH] mon/PGMap: fix stored_raw calculation 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 --- src/mon/PGMap.cc | 5 +++-- src/osd/osd_types.h | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 76404a965388e..1e580541bccda 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -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)); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index e7c50752fb8df..598b1478e612e 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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; -- 2.39.5