auto obj_ctx = store->svc.sysobj->init_obj_ctx();
+ rgw::bucket_index_layout_generation generator;
+ uint64_t gen_number = generator.gen;
+
RGWBucketInfo bucket_info;
RGWBucketInfo* bucket_info_p =
bucket_info_out ? bucket_info_out : &bucket_info;
string oid;
- ret = store->svc.bi_rados->open_bucket_index_shard(*bucket_info_p, shard_id, &bucket_obj);
+ ret = store->svc.bi_rados->open_bucket_index_shard(*bucket_info_p, shard_id, gen_number, &bucket_obj);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: open_bucket_index_shard() returned ret=" << ret << dendl;
return ret;
{
bucket = bucket_info.bucket;
shard_id = sid;
+ rgw::bucket_index_layout_generation generator;
+ uint64_t gen_number = generator.gen;
- int ret = store->svc.bi_rados->open_bucket_index_shard(bucket_info, shard_id, &bucket_obj);
+ int ret = store->svc.bi_rados->open_bucket_index_shard(bucket_info, shard_id, gen_number, &bucket_obj);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: open_bucket_index_shard() returned ret=" << ret << dendl;
return ret;
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)
{
if (!num_shards) {
// By default with no sharding, we use the bucket oid as itself
(*bucket_obj) = bucket_oid_base;
} else {
- char buf[bucket_oid_base.size() + 32];
- snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), shard_id);
- (*bucket_obj) = buf;
+ char buf[bucket_oid_base.size() + 64];
+ if (gen_id != 0) {
+ snprintf(buf, sizeof(buf), "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, shard_id);
+ (*bucket_obj) = buf;
+ } else {
+ snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), shard_id);
+ (*bucket_obj) = buf;
+ }
}
}
int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket_info,
int shard_id,
+ uint64_t gen_id,
RGWSI_RADOS::Obj *bucket_obj)
{
RGWSI_RADOS::Pool index_pool;
string oid;
get_bucket_index_object(bucket_oid_base, bucket_info.layout.current_index.layout.normal.num_shards,
- shard_id, &oid);
+ shard_id, gen_id, &oid);
*bucket_obj = svc.rados->obj(index_pool, oid);
void get_bucket_index_object(const string& bucket_oid_base,
uint32_t num_shards,
int shard_id,
+ uint64_t gen_id,
string *bucket_obj);
int get_bucket_index_object(const string& bucket_oid_base, const string& obj_key,
uint32_t num_shards, rgw::BucketHashType hash_type,
int *shard_id);
int open_bucket_index_shard(const RGWBucketInfo& bucket_info,
- int shard_id,
+ int shard_id, uint64_t gen_id,
RGWSI_RADOS::Obj *bucket_obj);
int open_bucket_index(const RGWBucketInfo& bucket_info,