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 {
}
}
-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);
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;
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;
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);
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,
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,