From 44bcfdd416222f9392d16f4f15ea2b6304701544 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 19 May 2021 14:03:48 -0400 Subject: [PATCH] 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 --- src/rgw/services/svc_bi_rados.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rgw/services/svc_bi_rados.cc b/src/rgw/services/svc_bi_rados.cc index 984eaf487b8ca..a4b8916263041 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; } -- 2.39.5