From 0d61e3abc8eda12550eba01e538f301999c17c24 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 1 Mar 2023 16:06:14 -0500 Subject: [PATCH] rgw/rados: RGWSI_BucketIndex_RADOS requires layouts, not num_shards Signed-off-by: Casey Bodley (cherry picked from commit 46f89cbae76d68af83a712f42443466e466681a3) --- src/rgw/driver/rados/rgw_rados.cc | 5 ++-- src/rgw/services/svc_bi_rados.cc | 38 ++++++++++++++++--------------- src/rgw/services/svc_bi_rados.h | 21 ++++++++--------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 067ea9ca6e946..8afd91801717f 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -2749,9 +2749,8 @@ int RGWRados::BucketShard::init(const DoutPrefixProvider *dpp, bucket = bucket_info.bucket; shard_id = sid; - int ret = store->svc.bi_rados->open_bucket_index_shard(dpp, bucket_info, shard_id, - num_shards(index), index.gen, - &bucket_obj); + int ret = store->svc.bi_rados->open_bucket_index_shard(dpp, bucket_info, index, + shard_id, &bucket_obj); if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: open_bucket_index_shard() returned ret=" << ret << dendl; return ret; diff --git a/src/rgw/services/svc_bi_rados.cc b/src/rgw/services/svc_bi_rados.cc index c1725f0e369e3..6002b986f592b 100644 --- a/src/rgw/services/svc_bi_rados.cc +++ b/src/rgw/services/svc_bi_rados.cc @@ -216,13 +216,13 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index(const DoutPrefixProvider *dpp, return 0; } -void RGWSI_BucketIndex_RADOS::get_bucket_index_object(const string& bucket_oid_base, - uint32_t num_shards, - int shard_id, - uint64_t gen_id, - string *bucket_obj) +void RGWSI_BucketIndex_RADOS::get_bucket_index_object( + const std::string& bucket_oid_base, + const rgw::bucket_index_normal_layout& normal, + uint64_t gen_id, int shard_id, + std::string* bucket_obj) { - if (!num_shards) { + if (!normal.num_shards) { // By default with no sharding, we use the bucket oid as itself (*bucket_obj) = bucket_oid_base; } else { @@ -239,21 +239,23 @@ void RGWSI_BucketIndex_RADOS::get_bucket_index_object(const string& bucket_oid_b } } -int RGWSI_BucketIndex_RADOS::get_bucket_index_object(const string& bucket_oid_base, const string& obj_key, - uint32_t num_shards, rgw::BucketHashType hash_type, - uint64_t gen_id, string *bucket_obj, int *shard_id) +int RGWSI_BucketIndex_RADOS::get_bucket_index_object( + const std::string& bucket_oid_base, + const rgw::bucket_index_normal_layout& normal, + uint64_t gen_id, const std::string& obj_key, + std::string* bucket_obj, int* shard_id) { int r = 0; - switch (hash_type) { + switch (normal.hash_type) { case rgw::BucketHashType::Mod: - if (!num_shards) { + if (!normal.num_shards) { // By default with no sharding, we use the bucket oid as itself (*bucket_obj) = bucket_oid_base; if (shard_id) { *shard_id = -1; } } else { - uint32_t sid = bucket_shard_index(obj_key, num_shards); + uint32_t sid = bucket_shard_index(obj_key, normal.num_shards); char buf[bucket_oid_base.size() + 64]; if (gen_id) { bucket_obj_with_generation(buf, sizeof(buf), bucket_oid_base, gen_id, sid); @@ -291,8 +293,9 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const DoutPrefixProvider *d string oid; - ret = get_bucket_index_object(bucket_oid_base, obj_key, bucket_info.layout.current_index.layout.normal.num_shards, - bucket_info.layout.current_index.layout.normal.hash_type, bucket_info.layout.current_index.gen, &oid, shard_id); + const auto& current_index = bucket_info.layout.current_index; + ret = get_bucket_index_object(bucket_oid_base, current_index.layout.normal, + current_index.gen, obj_key, &oid, shard_id); if (ret < 0) { ldpp_dout(dpp, 10) << "get_bucket_index_object() returned ret=" << ret << dendl; return ret; @@ -305,9 +308,8 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const DoutPrefixProvider *d int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, + const rgw::bucket_index_layout_generation& index, int shard_id, - uint32_t num_shards, - uint64_t gen, RGWSI_RADOS::Obj *bucket_obj) { RGWSI_RADOS::Pool index_pool; @@ -321,8 +323,8 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const DoutPrefixProvider *d string oid; - get_bucket_index_object(bucket_oid_base, num_shards, - shard_id, gen, &oid); + get_bucket_index_object(bucket_oid_base, index.layout.normal, + index.gen, shard_id, &oid); *bucket_obj = svc.rados->obj(index_pool, oid); diff --git a/src/rgw/services/svc_bi_rados.h b/src/rgw/services/svc_bi_rados.h index b541449963a90..feba0cfcd1936 100644 --- a/src/rgw/services/svc_bi_rados.h +++ b/src/rgw/services/svc_bi_rados.h @@ -56,15 +56,16 @@ class RGWSI_BucketIndex_RADOS : public RGWSI_BucketIndex RGWSI_RADOS::Pool *index_pool, std::string *bucket_oid_base); + // return the index oid for the given shard id void get_bucket_index_object(const std::string& bucket_oid_base, - uint32_t num_shards, - int shard_id, - uint64_t gen_id, - std::string *bucket_obj); + const rgw::bucket_index_normal_layout& normal, + uint64_t gen_id, int shard_id, + std::string* bucket_obj); + // return the index oid and shard id for the given object name int get_bucket_index_object(const std::string& bucket_oid_base, - const std::string& obj_key, - uint32_t num_shards, rgw::BucketHashType hash_type, - uint64_t gen_id, std::string *bucket_obj, int *shard_id); + const rgw::bucket_index_normal_layout& normal, + uint64_t gen_id, const std::string& obj_key, + std::string* bucket_obj, int* shard_id); int cls_bucket_head(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, @@ -145,10 +146,8 @@ public: int open_bucket_index_shard(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, - int shard_id, - uint32_t num_shards, - uint64_t gen, - RGWSI_RADOS::Obj *bucket_obj); + const rgw::bucket_index_layout_generation& index, + int shard_id, RGWSI_RADOS::Obj *bucket_obj); int open_bucket_index(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, -- 2.39.5