From: Casey Bodley Date: Wed, 19 May 2021 18:03:48 +0000 (-0400) Subject: rgw: get_bucket_instance_ids() uses num_shards from layout X-Git-Tag: v18.0.0~787^2~107 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=820c94b0fc2ae695f37119240263a03e8056388a;p=ceph.git rgw: get_bucket_instance_ids() uses num_shards from layout 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 --- diff --git a/src/rgw/services/svc_bi_rados.cc b/src/rgw/services/svc_bi_rados.cc index 984eaf487b8..a4b89162630 100644 --- a/src/rgw/services/svc_bi_rados.cc +++ b/src/rgw/services/svc_bi_rados.cc @@ -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 *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(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; }