- call init_index() on target layout during reshard process.
Takes const rgw::bucket_index_layout_generation&
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
objv_tracker = bci.info.objv_tracker;
- int ret = bihandler->svc.bi->init_index(dpp, bci.info);
+ int ret = bihandler->svc.bi->init_index(dpp, bci.info, bci.info.layout.current_index);
if (ret < 0) {
return ret;
}
info.quota = *pquota_info;
}
- int r = svc.bi->init_index(dpp, info);
+ int r = svc.bi->init_index(dpp, info, info.layout.current_index);
if (r < 0) {
return r;
}
/* only remove it if it's a different bucket instance */
if (orig_info.bucket.bucket_id != bucket.bucket_id) {
- int r = svc.bi->clean_index(dpp, info, std::nullopt);
+ int r = svc.bi->clean_index(dpp, info, info.layout.current_index.gen);
if (r < 0) {
ldpp_dout(dpp, 0) << "WARNING: could not remove bucket index (r=" << r << ")" << dendl;
}
bucket = bucket_info.bucket;
shard_id = sid;
- int ret = store->svc.bi_rados->open_bucket_index_shard(dpp, bucket_info, shard_id, current_layout.layout.normal.num_shards, std::nullopt, &bucket_obj);
+ int ret = store->svc.bi_rados->open_bucket_index_shard(dpp, bucket_info, shard_id, current_layout.layout.normal.num_shards, current_layout.gen, &bucket_obj);
if (ret < 0) {
ldpp_dout(dpp, 0) << "ERROR: open_bucket_index_shard() returned ret=" << ret << dendl;
return ret;
}
//increment generation number
+ bucket_info.layout.target_index->gen = bucket_info.layout.current_index.gen;
bucket_info.layout.target_index->gen++;
int num_target_shards = bucket_info.layout.target_index->layout.normal.num_shards;
while (is_truncated) {
entries.clear();
ret = store->getRados()->bi_list(dpp, bucket_info, i, null_object_filter, marker, max_entries, &entries, &is_truncated);
- if (ret < 0 && ret == -ENOENT) {
+ if (ret < 0 && ret != -ENOENT) {
derr << "ERROR: bi_list(): " << cpp_strerror(-ret) << dendl;
return ret;
}
} else if (out) {
(*out) << " " << total_entries << std::endl;
}
-
+
ret = target_shards_mgr.finish();
if (ret < 0) {
ldpp_dout(dpp, -1) << "ERROR: failed to reshard" << dendl;
return ret;
}
+ ret = store->svc()->bi->init_index(dpp, bucket_info, bucket_info.layout.current_index);
+ if (ret < 0) {
+ return ret;
+ }
+
return 0;
// NB: some error clean-up is done by ~BucketInfoReshardUpdate
} // RGWBucketReshard::do_reshard
// at this point since all we're using a best effort to remove old
// shard objects
- ret = store->svc()->bi->clean_index(dpp, bucket_info, std::nullopt);
+ ret = store->svc()->bi->clean_index(dpp, bucket_info, bucket_info.layout.current_index.gen);
if (ret < 0) {
lderr(store->ctx()) << "Error: " << __func__ <<
" failed to clean up old shards; " <<
RGWSI_BucketIndex(CephContext *cct) : RGWServiceInstance(cct) {}
virtual ~RGWSI_BucketIndex() {}
- virtual int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info) = 0;
- virtual int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, std::optional<uint64_t> gen) = 0;
+ virtual int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout) = 0;
+ virtual int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, uint64_t gen) = 0;
virtual int read_stats(const DoutPrefixProvider *dpp,
const RGWBucketInfo& bucket_info,
}
static void get_bucket_index_objects(const string& bucket_oid_base,
- uint32_t num_shards, std::optional<uint64_t> _gen_id,
+ uint32_t num_shards, uint64_t gen_id,
map<int, string> *_bucket_objects,
int shard_id = -1)
{
auto& bucket_objects = *_bucket_objects;
- auto gen_id = _gen_id.value_or(0);
if (!num_shards) {
bucket_objects[0] = bucket_oid_base;
} else {
void RGWSI_BucketIndex_RADOS::get_bucket_index_object(const string& bucket_oid_base,
uint32_t num_shards,
int shard_id,
- std::optional<uint64_t> _gen_id,
+ uint64_t gen_id,
string *bucket_obj)
{
- auto gen_id = _gen_id.value_or(0);
if (!num_shards) {
// By default with no sharding, we use the bucket oid as itself
(*bucket_obj) = bucket_oid_base;
const RGWBucketInfo& bucket_info,
int shard_id,
uint32_t num_shards,
- std::optional<uint64_t> gen,
+ uint64_t gen,
RGWSI_RADOS::Obj *bucket_obj)
{
RGWSI_RADOS::Pool index_pool;
return 0;
}
-int RGWSI_BucketIndex_RADOS::init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info)
+int RGWSI_BucketIndex_RADOS::init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout)
{
RGWSI_RADOS::Pool index_pool;
dir_oid.append(bucket_info.bucket.bucket_id);
map<int, string> bucket_objs;
- get_bucket_index_objects(dir_oid, bucket_info.layout.current_index.layout.normal.num_shards, std::nullopt, &bucket_objs);
+ get_bucket_index_objects(dir_oid, idx_layout.layout.normal.num_shards, idx_layout.gen, &bucket_objs);
return CLSRGWIssueBucketIndexInit(index_pool.ioctx(),
bucket_objs,
cct->_conf->rgw_bucket_index_max_aio)();
}
-int RGWSI_BucketIndex_RADOS::clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, std::optional<uint64_t> gen)
+int RGWSI_BucketIndex_RADOS::clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, uint64_t gen)
{
RGWSI_RADOS::Pool index_pool;
void get_bucket_index_object(const std::string& bucket_oid_base,
uint32_t num_shards,
int shard_id,
- std::optional<uint64_t> gen_id,
- std::string* bucket_obj);
+ uint64_t gen_id,
+ std::string *bucket_obj);
int get_bucket_index_object(const std::string& bucket_oid_base,
const std::string& obj_key,
uint32_t num_shards, rgw::BucketHashType hash_type,
return rgw_shards_mod(sid2, num_shards);
}
- int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info);
- int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, std::optional<uint64_t> gen);
+ int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,
+ const rgw::bucket_index_layout_generation& idx_layout) override;
+ int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,
+ uint64_t gen) override;
/* RADOS specific */
const RGWBucketInfo& bucket_info,
int shard_id,
uint32_t num_shards,
- std::optional<uint64_t> gen,
+ uint64_t gen,
RGWSI_RADOS::Obj *bucket_obj);
int open_bucket_index(const DoutPrefixProvider *dpp,