return 0;
}
-int RGWRados::SystemObject::Read::stat(RGWObjVersionTracker *objv_tracker)
-{
- RGWRados *store = source->get_store();
- rgw_raw_obj& obj = source->get_obj();
-
- return store->stat_system_obj(source->get_ctx(), state, obj, stat_params.attrs,
- stat_params.lastmod, stat_params.obj_size, objv_tracker);
-}
-int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op, const string *write_tag)
+int RGWRados::Bucket::UpdateIndex::guard_reshard(BucketShard *pbs, std::function<int(BucketShard *)> call)
{
- if (blind) {
- return 0;
- }
RGWRados *store = target->get_store();
-
- if (write_tag && write_tag->length()) {
- optag = string(write_tag->c_str(), write_tag->length());
- } else {
- if (optag.empty()) {
- append_rand_alpha(store->ctx(), optag, optag, 32);
- }
- }
-
+ BucketShard *bs;
int r;
#define NUM_RESHARD_RETRIES 10
-
for (int i = 0; i < NUM_RESHARD_RETRIES; ++i) {
- BucketShard *bs;
int ret = get_bucket_shard(&bs);
if (ret < 0) {
ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
return ret;
}
- r = store->cls_obj_prepare_op(*bs, op, optag, obj, bilog_flags, zones_trace);
+ r = call(bs);
if (r != -ERR_BUSY_RESHARDING) {
break;
}
invalidate_bs();
}
+ if (r < 0) {
+ return r;
+ }
+
+ if (pbs) {
+ *pbs = bs;
+ }
+
+ return 0;
+}
+
+int RGWRados::SystemObject::Read::stat(RGWObjVersionTracker *objv_tracker)
+{
+ RGWRados *store = source->get_store();
+ rgw_raw_obj& obj = source->get_obj();
+
+ return store->stat_system_obj(source->get_ctx(), state, obj, stat_params.attrs,
+ stat_params.lastmod, stat_params.obj_size, objv_tracker);
+}
+
+int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op, const string *write_tag)
+{
+ if (blind) {
+ return 0;
+ }
+ RGWRados *store = target->get_store();
+
+ if (write_tag && write_tag->length()) {
+ optag = string(write_tag->c_str(), write_tag->length());
+ } else {
+ if (optag.empty()) {
+ append_rand_alpha(store->ctx(), optag, optag, 32);
+ }
+ }
+
+ int r = guard_reshard(nullptr, [&](BucketShard *bs) -> int {
+ return store->cls_obj_prepare_op(*bs, op, optag, obj, bilog_flags, zones_trace);
+ });
+
if (r < 0) {
return r;
}
RGWRados *store = target->get_store();
BucketShard *bs;
- int ret = get_bucket_shard(&bs);
- if (ret < 0) {
- ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
- return ret;
- }
-
- ret = store->cls_obj_complete_cancel(*bs, optag, obj, bilog_flags, zones_trace);
+ ret = guard_reshard(&bs, [&](BucketShard *bs) -> int {
+ return store->cls_obj_complete_cancel(*bs, optag, obj, bilog_flags, zones_trace);
+ });
/*
* need to update data log anyhow, so that whoever follows needs to update its internal markers