From: J. Eric Ivancich Date: Tue, 4 Dec 2018 22:43:38 +0000 (-0500) Subject: rgw: fix bad user stats on versioned bucket after reshard X-Git-Tag: v13.2.9~77^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3e24fa634b452d8aeaeabfbc7c641af4af8131c2;p=ceph.git rgw: fix bad user stats on versioned bucket after reshard User stats should only count bucket index entries that refer to actual data. So only count entries with categories MAIN or MULTIMETA. Note: the full solution is provided by the combination of the fixes in PR 25333 (https://github.com/ceph/ceph/pull/25333) and these changes. Signed-off-by: J. Eric Ivancich (cherry picked from commit 8cd7ff99dd6cb7b3d63b80e09c8a2f229445e0a1) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index a806be7690cb..8f5a9458826f 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -13908,7 +13908,8 @@ int RGWRados::cls_user_get_header_async(const string& user_id, RGWGetUserHeader_ return 0; } -int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, const RGWBucketInfo& bucket_info) +int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, + const RGWBucketInfo& bucket_info) { vector headers; int r = cls_bucket_head(bucket_info, RGW_NO_SHARD, headers); @@ -13923,10 +13924,13 @@ int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, const RGWBucketI for (const auto& hiter : headers) { for (const auto& iter : hiter.stats) { - const struct rgw_bucket_category_stats& header_stats = iter.second; - entry.size += header_stats.total_size; - entry.size_rounded += header_stats.total_size_rounded; - entry.count += header_stats.num_entries; + if (uint8_t(RGW_OBJ_CATEGORY_MAIN) == iter.first || + uint8_t(RGW_OBJ_CATEGORY_MULTIMETA) == iter.first) { + const struct rgw_bucket_category_stats& header_stats = iter.second; + entry.size += header_stats.total_size; + entry.size_rounded += header_stats.total_size_rounded; + entry.count += header_stats.num_entries; + } } }