/* 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, info.layout.current_index.gen);
- if (r < 0) {
+ int r = svc.bi->clean_index(dpp, info, info.layout.current_index);
+ if (r < 0) {
ldpp_dout(dpp, 0) << "WARNING: could not remove bucket index (r=" << r << ")" << dendl;
}
r = ctl.bucket->remove_bucket_instance_info(info.bucket, info, null_yield, dpp);
}
//overwrite current_index for the next reshard process
+ const auto prev_index = bucket_info.layout.current_index;
bucket_info.layout.current_index = *bucket_info.layout.target_index;
bucket_info.layout.target_index = std::nullopt; // target_layout doesn't need to exist after reshard
bucket_info.layout.resharding = rgw::BucketReshardState::None;
return ret;
}
+ // resharding successful, so remove old bucket index shards; use
+ // best effort and don't report out an error; the lock isn't needed
+ // at this point since all we're using a best effor to to remove old
+ // shard objects
+
+ ret = store->svc()->bi->clean_index(dpp, bucket_info, prev_index);
+ if (ret < 0) {
+ ldpp_dout(dpp, -1) << "Error: " << __func__ <<
+ " failed to clean up old shards; " <<
+ "RGWRados::clean_bucket_index returned " << ret << dendl;
+ }
+
return 0;
// NB: some error clean-up is done by ~BucketInfoReshardUpdate
} // RGWBucketReshard::do_reshard
reshard_lock.unlock();
- // resharding successful, so remove old bucket index shards; use
- // best effort and don't report out an error; the lock isn't needed
- // 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, bucket_info.layout.current_index.gen);
- if (ret < 0) {
- lderr(store->ctx()) << "Error: " << __func__ <<
- " failed to clean up old shards; " <<
- "RGWRados::clean_bucket_index returned " << ret << dendl;
- }
-
ldpp_dout(dpp, 1) << __func__ <<
" INFO: reshard of bucket \"" << bucket_info.bucket.name << "\" completed successfully" << dendl;
// since the real problem is the issue that led to this error code
// path, we won't touch ret and instead use another variable to
// temporarily error codes
- int ret2 = store->svc()->bi->clean_index(dpp, bucket_info, bucket_info.layout.target_index->gen);
+ int ret2 = store->svc()->bi->clean_index(dpp, bucket_info, bucket_info.layout.current_index);
if (ret2 < 0) {
ldpp_dout(dpp, -1) << "Error: " << __func__ <<
" failed to clean up shards from failed incomplete resharding; " <<
virtual ~RGWSI_BucketIndex() {}
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 clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout) = 0;
virtual int read_stats(const DoutPrefixProvider *dpp,
const RGWBucketInfo& bucket_info,
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,
- string *bucket_obj, int *shard_id)
+ uint64_t gen_id, string *bucket_obj, int *shard_id)
{
int r = 0;
switch (hash_type) {
}
} else {
uint32_t sid = bucket_shard_index(obj_key, num_shards);
- char buf[bucket_oid_base.size() + 32];
- snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), sid);
+ char buf[bucket_oid_base.size() + 64];
+ if (gen_id) {
+ snprintf(buf, sizeof(buf), "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, sid);
+ } else {
+ snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), sid);
+ }
(*bucket_obj) = buf;
if (shard_id) {
*shard_id = (int)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, &oid, shard_id);
+ bucket_info.layout.current_index.layout.normal.hash_type, bucket_info.layout.current_index.gen, &oid, shard_id);
if (ret < 0) {
ldpp_dout(dpp, 10) << "get_bucket_index_object() returned ret=" << ret << dendl;
return ret;
cct->_conf->rgw_bucket_index_max_aio)();
}
-int RGWSI_BucketIndex_RADOS::clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, uint64_t gen)
+int RGWSI_BucketIndex_RADOS::clean_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);
std::map<int, std::string> bucket_objs;
- get_bucket_index_objects(dir_oid, bucket_info.layout.current_index.layout.normal.num_shards, gen, &bucket_objs);
+ get_bucket_index_objects(dir_oid, idx_layout.layout.normal.num_shards,
+ idx_layout.gen, &bucket_objs);
return CLSRGWIssueBucketIndexClean(index_pool.ioctx(),
bucket_objs,
int get_bucket_index_object(const std::string& bucket_oid_base,
const std::string& obj_key,
uint32_t num_shards, rgw::BucketHashType hash_type,
- std::string* bucket_obj, int* shard_id);
+ uint64_t gen_id, std::string *bucket_obj, int *shard_id);
int cls_bucket_head(const DoutPrefixProvider *dpp,
const RGWBucketInfo& bucket_info,
return rgw_shards_mod(sid2, num_shards);
}
- 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;
+ int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,const rgw::bucket_index_layout_generation& idx_layout);
+ int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout);
/* RADOS specific */