]> 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)
committerCasey Bodley <cbodley@redhat.com>
Fri, 27 May 2022 19:47:32 +0000 (15:47 -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 984eaf487b8ca532588c956effd901dea62ebd32..a4b89162630418fc0df331678e1956c77903db1d 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;
 }