From: Shilpa Jagannath Date: Tue, 31 Mar 2020 11:20:58 +0000 (+0530) Subject: modified get_target_shard_id() to take bucket_index_normal_layout directly X-Git-Tag: v16.1.0~2727^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F34096%2Fhead;p=ceph.git modified get_target_shard_id() to take bucket_index_normal_layout directly Signed-off-by: Shilpa Jagannath --- diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h index 69030d030160..cb84bd184425 100644 --- a/src/rgw/rgw_bucket_layout.h +++ b/src/rgw/rgw_bucket_layout.h @@ -30,12 +30,12 @@ enum class BucketHashType : uint8_t { Mod, // rjenkins hash of object name, modulo num_shards }; -inline std::ostream& operator<<(std::ostream& out, const rgw::BucketIndexType &index_type) +inline std::ostream& operator<<(std::ostream& out, const BucketIndexType &index_type) { switch (index_type) { - case rgw::BucketIndexType::Normal: + case BucketIndexType::Normal: return out << "Normal"; - case rgw::BucketIndexType::Indexless: + case BucketIndexType::Indexless: return out << "Indexless"; default: return out << "Unknown"; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 56512156d2e7..4f3e2f0c2e17 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -8953,18 +8953,18 @@ int RGWRados::check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 1, obj_size); } -int RGWRados::get_target_shard_id(const RGWBucketInfo& bucket_info, const string& obj_key, +int RGWRados::get_target_shard_id(const rgw::bucket_index_normal_layout& layout, const string& obj_key, int *shard_id) { int r = 0; - switch (bucket_info.layout.current_index.layout.normal.hash_type) { + switch (layout.hash_type) { case rgw::BucketHashType::Mod: - if (!bucket_info.layout.current_index.layout.normal.num_shards) { + if (!layout.num_shards) { if (shard_id) { *shard_id = -1; } } else { - uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, bucket_info.layout.current_index.layout.normal.num_shards); + uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, layout.num_shards); if (shard_id) { *shard_id = (int)sid; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 5d0e580c87b7..db3c2bd6ebbf 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1425,7 +1425,7 @@ public: uint64_t end_epoch); int cls_obj_usage_log_clear(string& oid); - int get_target_shard_id(const RGWBucketInfo& bucket_info, const string& obj_key, int *shard_id); + int get_target_shard_id(const rgw::bucket_index_normal_layout& layout, const string& obj_key, int *shard_id); int lock_exclusive(const rgw_pool& pool, const string& oid, ceph::timespan& duration, rgw_zone_id& zone_id, string& owner_id); int unlock(const rgw_pool& pool, const string& oid, rgw_zone_id& zone_id, string& owner_id); diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index d1a5af6ed3cf..d1d42fde1c66 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -525,6 +525,7 @@ int RGWBucketReshard::do_reshard(int num_shards, Formatter *formatter) { rgw_bucket& bucket = bucket_info.bucket; + rgw::bucket_index_normal_layout layout; int ret = 0; @@ -611,7 +612,7 @@ int RGWBucketReshard::do_reshard(int num_shards, // place the multipart .meta object on the same shard as its head object obj.index_hash_source = mp.get_key(); } - int ret = store->getRados()->get_target_shard_id(new_bucket_info, obj.get_hash_object(), &target_shard_id); + int ret = store->getRados()->get_target_shard_id(layout, obj.get_hash_object(), &target_shard_id); if (ret < 0) { lderr(store->ctx()) << "ERROR: get_target_shard_id() returned ret=" << ret << dendl; return ret;