From 248fbce6b54f6c91e63b05861f8631ca64c8df81 Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Wed, 28 Jul 2021 13:52:29 -0400 Subject: [PATCH] rgw: user stats showing 0 value for "size_utilized" and "size_kb_utilized" fields When accumulating user stats, the "utilized" fields are not looked at. Updates RGWStorageStats::dump so it only outputs the "utilized" data if they're updated. Signed-off-by: J. Eric Ivancich --- src/rgw/rgw_admin.cc | 7 ++++--- src/rgw/rgw_common.h | 16 ++++++++-------- src/rgw/rgw_json_enc.cc | 8 ++++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 3a52b17bdf0f..62a98b5903ce 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -7483,12 +7483,13 @@ next: } } - RGWStorageStats stats; + constexpr bool omit_utilized_stats = false; + RGWStorageStats stats(omit_utilized_stats); ceph::real_time last_stats_sync; ceph::real_time last_stats_update; int ret = static_cast(store)->ctl()->user->read_stats(dpp(), user->get_id(), &stats, null_yield, - &last_stats_sync, - &last_stats_update); + &last_stats_sync, + &last_stats_update); if (ret < 0) { if (ret == -ENOENT) { /* in case of ENOENT */ cerr << "User has not been initialized or user does not exist" << std::endl; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index f4ac4c2795d9..80e6059c623f 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -14,8 +14,7 @@ * */ -#ifndef CEPH_RGW_COMMON_H -#define CEPH_RGW_COMMON_H +#pragma once #include #include @@ -1145,17 +1144,20 @@ struct RGWStorageStats RGWObjCategory category; uint64_t size; uint64_t size_rounded; - uint64_t size_utilized{0}; //< size after compression, encryption uint64_t num_objects; + uint64_t size_utilized{0}; //< size after compression, encryption + bool dump_utilized; // whether dump should include utilized values - RGWStorageStats() + RGWStorageStats(bool _dump_utilized=true) : category(RGWObjCategory::None), size(0), size_rounded(0), - num_objects(0) {} + num_objects(0), + dump_utilized(_dump_utilized) + {} void dump(Formatter *f) const; -}; +}; // RGWStorageStats class RGWEnv; @@ -2352,5 +2354,3 @@ int decode_bl(bufferlist& bl, T& t) } return 0; } - -#endif diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index b3ceff68e757..d8d14bb2f2cd 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -686,10 +686,14 @@ void RGWStorageStats::dump(Formatter *f) const { encode_json("size", size, f); encode_json("size_actual", size_rounded, f); - encode_json("size_utilized", size_utilized, f); + if (dump_utilized) { + encode_json("size_utilized", size_utilized, f); + } encode_json("size_kb", rgw_rounded_kb(size), f); encode_json("size_kb_actual", rgw_rounded_kb(size_rounded), f); - encode_json("size_kb_utilized", rgw_rounded_kb(size_utilized), f); + if (dump_utilized) { + encode_json("size_kb_utilized", rgw_rounded_kb(size_utilized), f); + } encode_json("num_objects", num_objects, f); } -- 2.47.3