]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: get_bucket_instance_ids() uses num_shards from layout
authorCasey Bodley <cbodley@redhat.com>
Wed, 19 May 2021 18:03:48 +0000 (14:03 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 13 Sep 2021 16:27:50 +0000 (12:27 -0400)
knock out a TODO that was causing this assertion failure in
RGWRados::get_bucket_stats() after a reshard:

  ceph_assert(headers.size() == bucket_instance_ids.size());

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/services/svc_bi_rados.cc

index 97c07c87202cb2eb4c61a3c1cc3e2ec41ee3c95a..afa6223b0245bb5320e9db411d2375ff1a0ea59b 100644 (file)
@@ -165,23 +165,23 @@ static void get_bucket_index_objects(const string& bucket_oid_base,
 }
 
 static void get_bucket_instance_ids(const RGWBucketInfo& bucket_info,
-                                    int shard_id,
+                                    int num_shards, int shard_id,
                                     map<int, string> *result)
 {
   const rgw_bucket& bucket = bucket_info.bucket;
   string plain_id = bucket.name + ":" + bucket.bucket_id;
 
-  if (!bucket_info.layout.current_index.layout.normal.num_shards) {
+  if (!num_shards) {
     (*result)[0] = plain_id;
   } else {
     char buf[16];
     if (shard_id < 0) {
-      for (uint32_t i = 0; i < bucket_info.layout.current_index.layout.normal.num_shards; ++i) {
+      for (int i = 0; i < num_shards; ++i) {
         snprintf(buf, sizeof(buf), ":%d", i);
         (*result)[i] = plain_id + buf;
       }
     } else {
-      if (static_cast<uint32_t>(shard_id) > bucket_info.layout.current_index.layout.normal.num_shards) {
+      if (shard_id > num_shards) {
         return;
       }
       snprintf(buf, sizeof(buf), ":%d", shard_id);
@@ -210,8 +210,8 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index(const DoutPrefixProvider *dpp,
   get_bucket_index_objects(bucket_oid_base, idx_layout.layout.normal.num_shards,
                            idx_layout.gen, bucket_objs, shard_id);
   if (bucket_instance_ids) {
-    // TODO: generation need to be passed here
-    get_bucket_instance_ids(bucket_info, shard_id, bucket_instance_ids);
+    get_bucket_instance_ids(bucket_info, idx_layout.layout.normal.num_shards,
+                            shard_id, bucket_instance_ids);
   }
   return 0;
 }