int ret = 0;
cls_rgw_bucket_instance_entry entry;
+ // gets loaded by fetch_new_bucket_info; can be used by
+ // clear_resharding
+ std::map<std::string, bufferlist> bucket_attrs;
+
// since we want to run this recovery code from two distinct places,
// let's just put it in a lambda so we can easily re-use; if the
// lambda successfully fetches a new bucket id, it sets
// new_bucket_id and returns 0, otherwise it returns a negative
// error code
auto fetch_new_bucket_info =
- [this, &bucket_info, dpp](const std::string& log_tag) -> int {
- int ret = try_refresh_bucket_info(bucket_info, nullptr, dpp);
+ [this, &bucket_info, &bucket_attrs, dpp](const std::string& log_tag) -> int {
+ int ret = try_refresh_bucket_info(bucket_info, nullptr, dpp, &bucket_attrs);
if (ret < 0) {
ldpp_dout(dpp, 0) << __func__ <<
" ERROR: failed to refresh bucket info after reshard at " <<
ldpp_dout(dpp, 10) << __PRETTY_FUNCTION__ <<
": was able to take reshard lock for bucket " <<
bucket_id << dendl;
- // the reshard may have finished, so call clear_resharding() with its current bucket info
+ // the reshard may have finished, so call clear_resharding()
+ // with its current bucket info; ALSO this will load
+ // bucket_attrs for call to clear_resharding below
ret = fetch_new_bucket_info("trying_to_clear_resharding");
if (ret < 0) {
reshard_lock.unlock();
bucket_id << dendl;
continue; // try again
}
- ret = RGWBucketReshard::clear_resharding(this->store, bucket_info, dpp);
+ ret = RGWBucketReshard::clear_resharding(this->store, bucket_info, bucket_attrs, dpp);
if (ret < 0) {
reshard_lock.unlock();
ldpp_dout(dpp, 0) << __PRETTY_FUNCTION__ <<
// it from the bucket instance metadata
static int revert_target_layout(rgw::sal::RadosStore* store,
RGWBucketInfo& bucket_info,
+ std::map<std::string, bufferlist>& bucket_attrs,
const ReshardFaultInjector& fault,
const DoutPrefixProvider* dpp)
{
if (ret = fault.check("revert_target_layout");
ret == 0) { // no fault injected, revert the bucket instance metadata
ret = store->getRados()->put_bucket_instance_info(bucket_info, false,
- real_time(), nullptr, dpp);
+ real_time(),
+ &bucket_attrs, dpp);
}
if (ret < 0) {
ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to pause "
"writes to the current index: " << cpp_strerror(ret) << dendl;
// clean up the target layout (ignore errors)
- revert_target_layout(store, bucket_info, fault, dpp);
+ revert_target_layout(store, bucket_info, bucket_attrs, fault, dpp);
return ret;
}
return 0;
static int cancel_reshard(rgw::sal::RadosStore* store,
RGWBucketInfo& bucket_info,
+ std::map<std::string, bufferlist>& bucket_attrs,
const ReshardFaultInjector& fault,
const DoutPrefixProvider *dpp)
{
}
if (bucket_info.layout.target_index) {
- return revert_target_layout(store, bucket_info, fault, dpp);
+ return revert_target_layout(store, bucket_info, bucket_attrs, fault, dpp);
}
// there is nothing to revert
return 0;
int RGWBucketReshard::clear_resharding(rgw::sal::RadosStore* store,
RGWBucketInfo& bucket_info,
+ std::map<std::string, bufferlist>& bucket_attrs,
const DoutPrefixProvider* dpp)
{
constexpr ReshardFaultInjector no_fault;
- return cancel_reshard(store, bucket_info, no_fault, dpp);
+ return cancel_reshard(store, bucket_info, bucket_attrs, no_fault, dpp);
}
int RGWBucketReshard::cancel(const DoutPrefixProvider* dpp)
ldpp_dout(dpp, -1) << "ERROR: bucket is not resharding" << dendl;
ret = -EINVAL;
} else {
- ret = clear_resharding(store, bucket_info, dpp);
+ ret = clear_resharding(store, bucket_info, bucket_attrs, dpp);
}
reshard_lock.unlock();
}
if (ret < 0) {
- cancel_reshard(store, bucket_info, fault, dpp);
+ cancel_reshard(store, bucket_info, bucket_attrs, fault, dpp);
ldpp_dout(dpp, 1) << __func__ << " INFO: reshard of bucket \""
<< bucket_info.bucket.name << "\" canceled due to errors" << dendl;