]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: fix bad user stats on versioned bucket after reshard
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 4 Dec 2018 22:43:38 +0000 (17:43 -0500)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 5 Dec 2018 18:26:47 +0000 (13:26 -0500)
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 <ivancich@redhat.com>
src/rgw/rgw_rados.cc

index 93ce2247ee4358b668d3a87d413c5cc8b270df05..5c0837892aa1af4acdce390de75cc4826462f762 100644 (file)
@@ -9475,7 +9475,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<rgw_bucket_dir_header> headers;
   int r = cls_bucket_head(bucket_info, RGW_NO_SHARD, headers);
@@ -9490,10 +9491,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;
+      }
     }
   }