From 0a15f54803b5ca3e72cde63a5976e0dfa179703f Mon Sep 17 00:00:00 2001 From: Shilpa Jagannath Date: Fri, 20 Mar 2020 23:46:24 +0530 Subject: [PATCH] rgw: replace RGWBucketInfo's sharding-related fields with BucketLayout Signed-off-by: Shilpa Jagannath --- src/rgw/rgw_admin.cc | 20 ++++++++++---------- src/rgw/rgw_bucket.cc | 16 ++++++++-------- src/rgw/rgw_common.cc | 14 +++++++------- src/rgw/rgw_common.h | 17 +++-------------- src/rgw/rgw_data_sync.cc | 21 +++++++++++---------- src/rgw/rgw_json_enc.cc | 14 +++++++------- src/rgw/rgw_op.cc | 4 ++-- src/rgw/rgw_rados.cc | 24 ++++++++++++------------ src/rgw/rgw_rados.h | 2 +- src/rgw/rgw_reshard.cc | 10 +++++----- src/rgw/rgw_trim_bilog.cc | 2 +- src/rgw/rgw_zone.h | 6 +++--- src/rgw/services/svc_bi_rados.cc | 23 ++++++++++++----------- src/rgw/services/svc_zone.cc | 2 +- 14 files changed, 83 insertions(+), 92 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 99285b4444346..dfe4218149ae3 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2731,7 +2731,7 @@ int check_reshard_bucket_params(rgw::sal::RGWRadosStore *store, return -EBUSY; } - int num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + int num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); if (num_shards <= num_source_shards && !yes_i_really_mean_it) { cerr << "num shards is less or equal to current shards count" << std::endl @@ -3179,7 +3179,7 @@ int main(int argc, const char **argv) boost::optional index_pool; boost::optional data_pool; boost::optional data_extra_pool; - RGWBucketIndexType placement_index_type = RGWBIType_Normal; + rgw::BucketIndexType placement_index_type = rgw::BucketIndexType::Normal; bool index_type_specified = false; boost::optional compression_type; @@ -3549,11 +3549,11 @@ int main(int argc, const char **argv) data_extra_pool = val; } else if (ceph_argparse_witharg(args, i, &val, "--placement-index-type", (char*)NULL)) { if (val == "normal") { - placement_index_type = RGWBIType_Normal; + placement_index_type = rgw::BucketIndexType::Normal; } else if (val == "indexless") { - placement_index_type = RGWBIType_Indexless; + placement_index_type = rgw::BucketIndexType::Indexless; } else { - placement_index_type = (RGWBucketIndexType)strict_strtol(val.c_str(), 10, &err); + placement_index_type = (rgw::BucketIndexType)strict_strtol(val.c_str(), 10, &err); if (!err.empty()) { cerr << "ERROR: failed to parse index type index: " << err << std::endl; return EINVAL; @@ -6513,14 +6513,14 @@ next: max_entries = 1000; } - int max_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); formatter->open_array_section("entries"); int i = (specified_shard_id ? shard_id : 0); for (; i < max_shards; i++) { RGWRados::BucketShard bs(store->getRados()); - int shard_id = (bucket_info.num_shards > 0 ? i : -1); + int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? i : -1); int ret = bs.init(bucket, shard_id, nullptr /* no RGWBucketInfo */); marker.clear(); @@ -6580,11 +6580,11 @@ next: return EINVAL; } - int max_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); for (int i = 0; i < max_shards; i++) { RGWRados::BucketShard bs(store->getRados()); - int shard_id = (bucket_info.num_shards > 0 ? i : -1); + int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? i : -1); int ret = bs.init(bucket, shard_id, nullptr /* no RGWBucketInfo */); if (ret < 0) { cerr << "ERROR: bs.init(bucket=" << bucket << ", shard=" << shard_id << "): " << cpp_strerror(-ret) << std::endl; @@ -6881,7 +6881,7 @@ next: return ret; } - int num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + int num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); RGWReshard reshard(store); cls_rgw_reshard_entry entry; diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 108b1c13e2d1c..825cc1ad16999 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -1097,8 +1097,8 @@ int RGWBucket::sync(RGWBucketAdminOpState& op_state, map *at return r; } - int shards_num = bucket_info.num_shards? bucket_info.num_shards : 1; - int shard_id = bucket_info.num_shards? 0 : -1; + int shards_num = bucket_info.layout.current_index.layout.normal.num_shards? bucket_info.layout.current_index.layout.normal.num_shards : 1; + int shard_id = bucket_info.layout.current_index.layout.normal.num_shards? 0 : -1; if (!sync) { r = store->svc()->bilog_rados->log_stop(bucket_info, -1); @@ -1387,14 +1387,14 @@ static int bucket_stats(rgw::sal::RGWRadosStore *store, const std::string& tenan formatter->open_object_section("stats"); formatter->dump_string("bucket", bucket.name); - formatter->dump_int("num_shards", bucket_info.num_shards); + formatter->dump_int("num_shards", bucket_info.layout.current_index.layout.normal.num_shards); formatter->dump_string("tenant", bucket.tenant); formatter->dump_string("zonegroup", bucket_info.zonegroup); formatter->dump_string("placement_rule", bucket_info.placement_rule.to_str()); ::encode_json("explicit_placement", bucket.explicit_placement, formatter); formatter->dump_string("id", bucket.bucket_id); formatter->dump_string("marker", bucket.marker); - formatter->dump_stream("index_type") << bucket_info.index_type; + formatter->dump_stream("index_type") << bucket_info.layout.current_index.layout.type; ::encode_json("owner", bucket_info.owner, formatter); formatter->dump_string("ver", bucket_ver); formatter->dump_string("master_ver", master_ver); @@ -1496,7 +1496,7 @@ int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store, num_objects += s.second.num_objects; } - num_shards = info.num_shards; + num_shards = info.layout.current_index.layout.normal.num_shards; uint64_t objs_per_shard = (num_shards) ? num_objects/num_shards : num_objects; { @@ -1637,10 +1637,10 @@ int RGWBucketAdminOp::set_quota(rgw::sal::RGWRadosStore *store, RGWBucketAdminOp static int purge_bucket_instance(rgw::sal::RGWRadosStore *store, const RGWBucketInfo& bucket_info) { - int max_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); for (int i = 0; i < max_shards; i++) { RGWRados::BucketShard bs(store->getRados()); - int shard_id = (bucket_info.num_shards > 0 ? i : -1); + int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? i : -1); int ret = bs.init(bucket_info.bucket, shard_id, nullptr); if (ret < 0) { cerr << "ERROR: bs.init(bucket=" << bucket_info.bucket << ", shard=" << shard_id @@ -3032,7 +3032,7 @@ int RGWMetadataHandlerPut_BucketInstance::put_check() return ret; } } - bci.info.index_type = rule_info.index_type; + bci.info.layout.current_index.layout.type = rule_info.index_type; } else { /* existing bucket, keep its placement */ bci.info.bucket.explicit_placement = old_bci->info.bucket.explicit_placement; diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index f3c08f8873c3f..0545122d12393 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -2000,15 +2000,15 @@ void RGWBucketInfo::encode(bufferlist& bl) const { encode(placement_rule, bl); encode(has_instance_obj, bl); encode(quota, bl); - encode(num_shards, bl); - encode(bucket_index_shard_hash_type, bl); + encode(layout.current_index.layout.normal.num_shards, bl); + encode(layout.current_index.layout.normal.hash_type, bl); encode(requester_pays, bl); encode(owner.tenant, bl); encode(has_website, bl); if (has_website) { encode(website_conf, bl); } - encode((uint32_t)index_type, bl); + encode((uint32_t)layout.current_index.layout.type, bl); encode(swift_versioning, bl); if (swift_versioning) { encode(swift_ver_location, bl); @@ -2054,9 +2054,9 @@ void RGWBucketInfo::decode(bufferlist::const_iterator& bl) { if (struct_v >= 9) decode(quota, bl); if (struct_v >= 10) - decode(num_shards, bl); + decode(layout.current_index.layout.normal.num_shards, bl); if (struct_v >= 11) - decode(bucket_index_shard_hash_type, bl); + decode(layout.current_index.layout.normal.hash_type, bl); if (struct_v >= 12) decode(requester_pays, bl); if (struct_v >= 13) @@ -2072,9 +2072,9 @@ void RGWBucketInfo::decode(bufferlist::const_iterator& bl) { if (struct_v >= 15) { uint32_t it; decode(it, bl); - index_type = (RGWBucketIndexType)it; + layout.current_index.layout.type = (rgw::BucketIndexType)it; } else { - index_type = RGWBIType_Normal; + layout.current_index.layout.type = rgw::BucketIndexType::Normal; } swift_versioning = false; swift_ver_location.clear(); diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 34fb71b833b9f..4d6d866d98b99 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1091,17 +1091,12 @@ enum RGWBucketFlags { BUCKET_OBJ_LOCK_ENABLED = 0X20, }; -enum RGWBucketIndexType { - RGWBIType_Normal = 0, - RGWBIType_Indexless = 1, -}; - -inline ostream& operator<<(ostream& out, const RGWBucketIndexType &index_type) +inline ostream& operator<<(ostream& out, const rgw::BucketIndexType &index_type) { switch (index_type) { - case RGWBIType_Normal: + case rgw::BucketIndexType::Normal: return out << "Normal"; - case RGWBIType_Indexless: + case rgw::BucketIndexType::Indexless: return out << "Indexless"; default: return out << "Unknown"; @@ -1132,10 +1127,6 @@ struct RGWBucketInfo { // - value of 0 indicates there is no sharding (this is by default // before this feature is implemented). // - value of UINT32_T::MAX indicates this is a blind bucket. - uint32_t num_shards{0}; - - // Represents the bucket index shard hash type. - uint8_t bucket_index_shard_hash_type{MOD}; // Represents the shard number for blind bucket. const static uint32_t NUM_SHARDS_BLIND_BUCKET; @@ -1145,8 +1136,6 @@ struct RGWBucketInfo { bool has_website{false}; RGWBucketWebsiteConf website_conf; - RGWBucketIndexType index_type = RGWBIType_Normal; - bool swift_versioning{false}; string swift_ver_location; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index aeceb05099d13..94ad515453612 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -853,7 +853,7 @@ public: call(new RGWReadRESTResourceCR(sync_env->cct, sc->conn, sync_env->http_manager, path, pairs, &meta_info)); } - num_shards = meta_info.data.get_bucket_info().num_shards; + num_shards = meta_info.data.get_bucket_info().layout.current_index.layout.normal.num_shards; if (num_shards > 0) { for (i = 0; i < num_shards; i++) { char buf[16]; @@ -2822,11 +2822,12 @@ RGWRemoteBucketManager::RGWRemoteBucketManager(const DoutPrefixProvider *_dpp, conn = _conn; source_zone = _source_zone; - int num_shards = (source_bucket_info.num_shards <= 0 ? 1 : source_bucket_info.num_shards); + int num_shards = (source_bucket_info.layout.current_index.layout.normal.num_shards <= 0 ? + 1 : source_bucket_info.layout.current_index.layout.normal.num_shards); sync_pairs.resize(num_shards); - int cur_shard = std::min(source_bucket_info.num_shards, 0); + int cur_shard = std::min(source_bucket_info.layout.current_index.layout.normal.num_shards, 0); for (int i = 0; i < num_shards; ++i, ++cur_shard) { auto& sync_pair = sync_pairs[i]; @@ -2834,7 +2835,7 @@ RGWRemoteBucketManager::RGWRemoteBucketManager(const DoutPrefixProvider *_dpp, sync_pair.source_bs.bucket = source_bucket_info.bucket; sync_pair.dest_bs.bucket = dest_bucket; - sync_pair.source_bs.shard_id = (source_bucket_info.num_shards > 0 ? cur_shard : -1); + sync_pair.source_bs.shard_id = (source_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? cur_shard : -1); if (dest_bucket == source_bucket_info.bucket) { sync_pair.dest_bs.shard_id = sync_pair.source_bs.shard_id; @@ -4299,8 +4300,8 @@ int RGWRunBucketSourcesSyncCR::operate() { ldpp_dout(sync_env->dpp, 20) << __func__ << "(): sync pipe=" << *siter << dendl; - source_num_shards = siter->source.get_bucket_info().num_shards; - target_num_shards = siter->target.get_bucket_info().num_shards; + source_num_shards = siter->source.get_bucket_info().layout.current_index.layout.normal.num_shards; + target_num_shards = siter->target.get_bucket_info().layout.current_index.layout.normal.num_shards; if (source_bs) { sync_pair.source_bs = *source_bs; } else { @@ -4951,13 +4952,13 @@ class RGWCollectBucketSyncStatusCR : public RGWShardCollectCR { dest_bucket_info(dest_bucket_info), i(status->begin()), end(status->end()) { - shard_to_shard_sync = (source_bucket_info.num_shards == dest_bucket_info.num_shards); + shard_to_shard_sync = (source_bucket_info.layout.current_index.layout.normal.num_shards == dest_bucket_info.layout.current_index.layout.normal.num_shards); - source_bs = rgw_bucket_shard(source_bucket_info.bucket, source_bucket_info.num_shards > 0 ? 0 : -1); - dest_bs = rgw_bucket_shard(dest_bucket_info.bucket, dest_bucket_info.num_shards > 0 ? 0 : -1); + source_bs = rgw_bucket_shard(source_bucket_info.bucket, source_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? 0 : -1); + dest_bs = rgw_bucket_shard(dest_bucket_info.bucket, dest_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? 0 : -1); status->clear(); - status->resize(std::max(1, source_bucket_info.num_shards)); + status->resize(std::max(1, source_bucket_info.layout.current_index.layout.normal.num_shards)); i = status->begin(); end = status->end(); diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index dec0e32dfd99b..8083212e33b57 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -780,8 +780,8 @@ void RGWBucketInfo::dump(Formatter *f) const encode_json("placement_rule", placement_rule, f); encode_json("has_instance_obj", has_instance_obj, f); encode_json("quota", quota, f); - encode_json("num_shards", num_shards, f); - encode_json("bi_shard_hash_type", (uint32_t)bucket_index_shard_hash_type, f); + encode_json("num_shards", layout.current_index.layout.normal.num_shards, f); + encode_json("bi_shard_hash_type", (uint32_t)layout.current_index.layout.normal.hash_type, f); encode_json("requester_pays", requester_pays, f); encode_json("has_website", has_website, f); if (has_website) { @@ -789,7 +789,7 @@ void RGWBucketInfo::dump(Formatter *f) const } encode_json("swift_versioning", swift_versioning, f); encode_json("swift_ver_location", swift_ver_location, f); - encode_json("index_type", (uint32_t)index_type, f); + encode_json("index_type", (uint32_t)layout.current_index.layout.type, f); encode_json("mdsearch_config", mdsearch_config, f); encode_json("reshard_status", (int)reshard_status, f); encode_json("new_bucket_instance_id", new_bucket_instance_id, f); @@ -815,10 +815,10 @@ void RGWBucketInfo::decode_json(JSONObj *obj) { placement_rule.from_str(pr); JSONDecoder::decode_json("has_instance_obj", has_instance_obj, obj); JSONDecoder::decode_json("quota", quota, obj); - JSONDecoder::decode_json("num_shards", num_shards, obj); + JSONDecoder::decode_json("num_shards", layout.current_index.layout.normal.num_shards, obj); uint32_t hash_type; JSONDecoder::decode_json("bi_shard_hash_type", hash_type, obj); - bucket_index_shard_hash_type = (uint8_t)hash_type; + layout.current_index.layout.normal.num_shards = (uint8_t)hash_type; JSONDecoder::decode_json("requester_pays", requester_pays, obj); JSONDecoder::decode_json("has_website", has_website, obj); if (has_website) { @@ -828,7 +828,7 @@ void RGWBucketInfo::decode_json(JSONObj *obj) { JSONDecoder::decode_json("swift_ver_location", swift_ver_location, obj); uint32_t it; JSONDecoder::decode_json("index_type", it, obj); - index_type = (RGWBucketIndexType)it; + layout.current_index.layout.type = (rgw::BucketIndexType)it; JSONDecoder::decode_json("mdsearch_config", mdsearch_config, obj); int rs; JSONDecoder::decode_json("reshard_status", rs, obj); @@ -1317,7 +1317,7 @@ void RGWZonePlacementInfo::decode_json(JSONObj *obj) JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj); uint32_t it; JSONDecoder::decode_json("index_type", it, obj); - index_type = (RGWBucketIndexType)it; + index_type = (rgw::BucketIndexType)it; /* backward compatibility, these are now defined in storage_classes */ string standard_compression_type; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index cb8e8a90d5333..9f64814e694ca 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3286,7 +3286,7 @@ void RGWCreateBucket::execute() ldpp_dout(this, 20) << "got creation time: << " << master_info.creation_time << dendl; pmaster_bucket= &master_info.bucket; creation_time = master_info.creation_time; - pmaster_num_shards = &master_info.num_shards; + pmaster_num_shards = &master_info.layout.current_index.layout.normal.num_shards; pobjv = &objv; obj_lock_enabled = master_info.obj_lock_enabled(); } else { @@ -7022,7 +7022,7 @@ int RGWBulkUploadOp::handle_dir(const boost::string_ref path) pmaster_bucket= &master_info.bucket; creation_time = master_info.creation_time; - pmaster_num_shards = &master_info.num_shards; + pmaster_num_shards = &master_info.layout.current_index.layout.normal.num_shards; pobjv = &objv; } else { pmaster_bucket = nullptr; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 3f6c32c8d4867..56512156d2e7f 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2211,15 +2211,15 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket, info.owner = owner.user_id; info.zonegroup = zonegroup_id; info.placement_rule = selected_placement_rule; - info.index_type = rule_info.index_type; + info.layout.current_index.layout.type = rule_info.index_type; info.swift_ver_location = swift_ver_location; info.swift_versioning = (!swift_ver_location.empty()); if (pmaster_num_shards) { - info.num_shards = *pmaster_num_shards; + info.layout.current_index.layout.normal.num_shards = *pmaster_num_shards; } else { - info.num_shards = bucket_index_max_shards; + info.layout.current_index.layout.normal.num_shards = bucket_index_max_shards; } - info.bucket_index_shard_hash_type = RGWBucketInfo::MOD; + info.layout.current_index.layout.normal.num_shards = RGWBucketInfo::MOD; info.requester_pays = false; if (real_clock::is_zero(creation_time)) { info.creation_time = ceph::real_clock::now(); @@ -7538,7 +7538,7 @@ public: int RGWRados::get_bucket_stats_async(RGWBucketInfo& bucket_info, int shard_id, RGWGetBucketStats_CB *ctx) { int num_aio = 0; - RGWGetBucketStatsContext *get_ctx = new RGWGetBucketStatsContext(ctx, bucket_info.num_shards ? : 1); + RGWGetBucketStatsContext *get_ctx = new RGWGetBucketStatsContext(ctx, bucket_info.layout.current_index.layout.normal.num_shards ? : 1); ceph_assert(get_ctx); int r = cls_bucket_head_async(bucket_info, shard_id, get_ctx, &num_aio); if (r < 0) { @@ -8886,7 +8886,7 @@ int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, bool need_resharding = false; uint32_t num_source_shards = - (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); const uint32_t max_dynamic_shards = uint32_t(cct->_conf.get_val("rgw_max_dynamic_shards")); @@ -8913,7 +8913,7 @@ int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, } ldout(cct, 20) << "RGWRados::" << __func__ << " bucket " << bucket.name << - " needs resharding; current num shards " << bucket_info.num_shards << + " needs resharding; current num shards " << bucket_info.layout.current_index.layout.normal.num_shards << "; new num shards " << final_num_shards << " (suggested " << suggested_num_shards << ")" << dendl; @@ -8924,7 +8924,7 @@ int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info, uint32_t n { RGWReshard reshard(this->store); - uint32_t num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + uint32_t num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); new_num_shards = std::min(new_num_shards, get_max_bucket_shards()); if (new_num_shards <= num_source_shards) { @@ -8957,14 +8957,14 @@ int RGWRados::get_target_shard_id(const RGWBucketInfo& bucket_info, const string int *shard_id) { int r = 0; - switch (bucket_info.bucket_index_shard_hash_type) { - case RGWBucketInfo::MOD: - if (!bucket_info.num_shards) { + switch (bucket_info.layout.current_index.layout.normal.hash_type) { + case rgw::BucketHashType::Mod: + if (!bucket_info.layout.current_index.layout.normal.num_shards) { if (shard_id) { *shard_id = -1; } } else { - uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, bucket_info.num_shards); + uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, bucket_info.layout.current_index.layout.normal.num_shards); if (shard_id) { *shard_id = (int)sid; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index e19b8d44811e6..5d0e580c87b79 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -945,7 +945,7 @@ public: UpdateIndex(RGWRados::Bucket *_target, const rgw_obj& _obj) : target(_target), obj(_obj), bs(target->get_store()) { - blind = (target->get_bucket_info().index_type == RGWBIType_Indexless); + blind = (target->get_bucket_info().layout.current_index.layout.type == rgw::BucketIndexType::Indexless); } int get_bucket_shard(BucketShard **pbs) { diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index e20d8a392388d..d1a5af6ed3cf9 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -107,7 +107,7 @@ public: store(_store), bucket_info(_bucket_info), bs(store->getRados()), aio_completions(_completions) { - num_shard = (bucket_info.num_shards > 0 ? _num_shard : -1); + num_shard = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? _num_shard : -1); bs.init(bucket_info.bucket, num_shard, nullptr /* no RGWBucketInfo */); max_aio_completions = @@ -304,7 +304,7 @@ int RGWBucketReshard::clear_resharding(rgw::sal::RGWRadosStore* store, int RGWBucketReshard::clear_index_shard_reshard_status(rgw::sal::RGWRadosStore* store, const RGWBucketInfo& bucket_info) { - uint32_t num_shards = bucket_info.num_shards; + uint32_t num_shards = bucket_info.layout.current_index.layout.normal.num_shards; if (num_shards < std::numeric_limits::max()) { int ret = set_resharding_status(store, bucket_info, @@ -332,7 +332,7 @@ static int create_new_bucket_instance(rgw::sal::RGWRadosStore *store, store->getRados()->create_bucket_id(&new_bucket_info.bucket.bucket_id); - new_bucket_info.num_shards = new_num_shards; + new_bucket_info.layout.current_index.layout.normal.num_shards = new_num_shards; new_bucket_info.objv_tracker.clear(); new_bucket_info.new_bucket_instance_id.clear(); @@ -556,7 +556,7 @@ int RGWBucketReshard::do_reshard(int num_shards, return ret; } - int num_target_shards = (new_bucket_info.num_shards > 0 ? new_bucket_info.num_shards : 1); + int num_target_shards = (new_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? new_bucket_info.layout.current_index.layout.normal.num_shards : 1); BucketReshardManager target_shards_mgr(store, new_bucket_info, num_target_shards); @@ -573,7 +573,7 @@ int RGWBucketReshard::do_reshard(int num_shards, } const int num_source_shards = - (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1); string marker; for (int i = 0; i < num_source_shards; ++i) { bool is_truncated = true; diff --git a/src/rgw/rgw_trim_bilog.cc b/src/rgw/rgw_trim_bilog.cc index 9e2ac89d218ed..1f5740e082acb 100644 --- a/src/rgw/rgw_trim_bilog.cc +++ b/src/rgw/rgw_trim_bilog.cc @@ -529,7 +529,7 @@ int BucketTrimInstanceCR::operate() // initialize each shard with the maximum marker, which is only used when // there are no peers syncing from us - min_markers.assign(std::max(1u, pbucket_info->num_shards), + min_markers.assign(std::max(1u, pbucket_info->layout.current_index.layout.normal.num_shards), RGWSyncLogTrimCR::max_marker); // determine the minimum marker for each shard diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index 090c3e3c30618..b29575af7951c 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -268,9 +268,9 @@ struct RGWZonePlacementInfo { rgw_pool index_pool; rgw_pool data_extra_pool; /* if not set we should use data_pool */ RGWZoneStorageClasses storage_classes; - RGWBucketIndexType index_type; + rgw::BucketIndexType index_type; - RGWZonePlacementInfo() : index_type(RGWBIType_Normal) {} + RGWZonePlacementInfo() : index_type(rgw::BucketIndexType::Normal) {} void encode(bufferlist& bl) const { ENCODE_START(7, 1, bl); @@ -301,7 +301,7 @@ struct RGWZonePlacementInfo { if (struct_v >= 5) { uint32_t it; decode(it, bl); - index_type = (RGWBucketIndexType)it; + index_type = (rgw::BucketIndexType)it; } string standard_compression_type; if (struct_v >= 6) { diff --git a/src/rgw/services/svc_bi_rados.cc b/src/rgw/services/svc_bi_rados.cc index 3ef0b6f09c21b..0aa71ea507ef3 100644 --- a/src/rgw/services/svc_bi_rados.cc +++ b/src/rgw/services/svc_bi_rados.cc @@ -142,17 +142,18 @@ static void get_bucket_instance_ids(const RGWBucketInfo& bucket_info, { const rgw_bucket& bucket = bucket_info.bucket; string plain_id = bucket.name + ":" + bucket.bucket_id; - if (!bucket_info.num_shards) { + + if (!bucket_info.layout.current_index.layout.normal.num_shards) { (*result)[0] = plain_id; } else { char buf[16]; if (shard_id < 0) { - for (uint32_t i = 0; i < bucket_info.num_shards; ++i) { + for (uint32_t i = 0; i < bucket_info.layout.current_index.layout.normal.num_shards; ++i) { snprintf(buf, sizeof(buf), ":%d", i); (*result)[i] = plain_id + buf; } } else { - if ((uint32_t)shard_id > bucket_info.num_shards) { + if ((uint32_t)shard_id > bucket_info.layout.current_index.layout.normal.num_shards) { return; } snprintf(buf, sizeof(buf), ":%d", shard_id); @@ -176,7 +177,7 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index(const RGWBucketInfo& bucket_info, return ret; } - get_bucket_index_objects(bucket_oid_base, bucket_info.num_shards, bucket_objs, shard_id); + get_bucket_index_objects(bucket_oid_base, bucket_info.layout.current_index.layout.normal.num_shards, bucket_objs, shard_id); if (bucket_instance_ids) { get_bucket_instance_ids(bucket_info, shard_id, bucket_instance_ids); } @@ -245,8 +246,8 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket string oid; - ret = get_bucket_index_object(bucket_oid_base, obj_key, bucket_info.num_shards, - (RGWBucketInfo::BIShardsHashType)bucket_info.bucket_index_shard_hash_type, &oid, shard_id); + ret = get_bucket_index_object(bucket_oid_base, obj_key, bucket_info.layout.current_index.layout.normal.num_shards, + (RGWBucketInfo::BIShardsHashType)bucket_info.layout.current_index.layout.normal.hash_type, &oid, shard_id); if (ret < 0) { ldout(cct, 10) << "get_bucket_index_object() returned ret=" << ret << dendl; return ret; @@ -272,7 +273,7 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket string oid; - get_bucket_index_object(bucket_oid_base, bucket_info.num_shards, + get_bucket_index_object(bucket_oid_base, bucket_info.layout.current_index.layout.normal.num_shards, shard_id, &oid); *bucket_obj = svc.rados->obj(index_pool, oid); @@ -322,7 +323,7 @@ int RGWSI_BucketIndex_RADOS::init_index(RGWBucketInfo& bucket_info) dir_oid.append(bucket_info.bucket.bucket_id); map bucket_objs; - get_bucket_index_objects(dir_oid, bucket_info.num_shards, &bucket_objs); + get_bucket_index_objects(dir_oid, bucket_info.layout.current_index.layout.normal.num_shards, &bucket_objs); return CLSRGWIssueBucketIndexInit(index_pool.ioctx(), bucket_objs, @@ -342,7 +343,7 @@ int RGWSI_BucketIndex_RADOS::clean_index(RGWBucketInfo& bucket_info) dir_oid.append(bucket_info.bucket.bucket_id); std::map bucket_objs; - get_bucket_index_objects(dir_oid, bucket_info.num_shards, &bucket_objs); + get_bucket_index_objects(dir_oid, bucket_info.layout.current_index.layout.normal.num_shards, &bucket_objs); return CLSRGWIssueBucketIndexClean(index_pool.ioctx(), bucket_objs, @@ -415,8 +416,8 @@ int RGWSI_BucketIndex_RADOS::handle_overwrite(const RGWBucketInfo& info, bool old_sync_enabled = orig_info.datasync_flag_enabled(); if (old_sync_enabled != new_sync_enabled) { - int shards_num = info.num_shards? info.num_shards : 1; - int shard_id = info.num_shards? 0 : -1; + int shards_num = info.layout.current_index.layout.normal.num_shards? info.layout.current_index.layout.normal.num_shards : 1; + int shard_id = info.layout.current_index.layout.normal.num_shards? 0 : -1; int ret; if (!new_sync_enabled) { diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index df5386930512b..e32aff9b3c985 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -1196,7 +1196,7 @@ read_omap: rule_info->storage_classes.set_storage_class(RGW_STORAGE_CLASS_STANDARD, &pool, nullptr); rule_info->data_extra_pool = pool_name; rule_info->index_pool = pool_name; - rule_info->index_type = RGWBIType_Normal; + rule_info->index_type = rgw::BucketIndexType::Normal; return 0; } -- 2.39.5