CLS_LOG(0, "ERROR: read_version(): failed to decode version entry\n");
return -EIO;
}
+ CLS_LOG(20, "cls_version: read_version %s:%d", objv->tag.c_str(), (int)objv->ver);
return 0;
}
int ret = read_version(hctx, &objv, false);
if (ret < 0)
return ret;
- CLS_LOG(20, "cls_version: read_version %s:%d", objv.tag.c_str(), (int)objv.ver);
if (!check_conds(op.conds, objv)) {
CLS_LOG(20, "cls_version: failed condition check");
return false;
}
- auto bliter = iter->second.begin();
+ auto bliter = iter->second.cbegin();
try {
decode(bliter);
} catch (buffer::error& err) {
ENCODE_FINISH(bl);
}
- void decode(bufferlist::iterator& bl) {
+ void decode(bufferlist::const_iterator& bl) {
DECODE_START(1, bl);
decode(orig_bucket, bl);
DECODE_FINISH(bl);
/* read original entrypoint */
RGWBucketEntryPoint be;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
map<string, bufferlist> attrs;
int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, be, &objv_tracker, &mtime, &attrs);
if (ret < 0) {
get_md5_digest(&new_be, md5_digest);
new_bucket_name = ami.orig_bucket.name + "-deleted-" + md5_digest;
-ldout(store->ctx(), 0) << __FILE__ << ":" << __LINE__ << ": new_bucket_name==" << new_bucket_name << dendl;
new_bi.bucket.name = new_bucket_name;
new_bi.objv_tracker.clear();
lderr(store->ctx()) << "could not delete bucket=" << entry << dendl;
}
- ret = rgw_delete_system_obj(store, store->get_zone_params().domain_root, RGW_BUCKET_INSTANCE_MD_PREFIX + meta_name, NULL);
+ ret = rgw_delete_system_obj(store, store->svc.zone->get_zone_params().domain_root, RGW_BUCKET_INSTANCE_MD_PREFIX + meta_name, NULL);
/* idempotent */
rgw_obj src_obj(bucket_info.bucket, key);
- rgw_obj dest_obj(src_obj);
+ rgw_obj dest_obj(bucket_info.bucket, dest_key.value_or(key));
int r = store->fetch_remote_obj(obj_ctx,
user_id,
std::optional<rgw_placement_rule> dest_placement_rule;
rgw_obj_key key;
+ std::optional<rgw_obj_key> dest_key;
std::optional<uint64_t> versioned_epoch;
real_time src_mtime;
RGWBucketInfo& _bucket_info,
std::optional<rgw_placement_rule> _dest_placement_rule,
const rgw_obj_key& _key,
+ const std::optional<rgw_obj_key>& _dest_key,
std::optional<uint64_t> _versioned_epoch,
bool _if_newer, rgw_zone_set *_zones_trace) : RGWAsyncRadosRequest(caller, cn), store(_store),
source_zone(_source_zone),
bucket_info(_bucket_info),
dest_placement_rule(_dest_placement_rule),
key(_key),
+ dest_key(_dest_key),
versioned_epoch(_versioned_epoch),
copy_if_newer(_if_newer)
{
std::optional<rgw_placement_rule> dest_placement_rule;
rgw_obj_key key;
+ std::optional<rgw_obj_key> dest_key;
std::optional<uint64_t> versioned_epoch;
real_time src_mtime;
RGWBucketInfo& _bucket_info,
std::optional<rgw_placement_rule> _dest_placement_rule,
const rgw_obj_key& _key,
+ const std::optional<rgw_obj_key>& _dest_key,
std::optional<uint64_t> _versioned_epoch,
bool _if_newer, rgw_zone_set *_zones_trace) : RGWSimpleCoroutine(_store->ctx()), cct(_store->ctx()),
async_rados(_async_rados), store(_store),
bucket_info(_bucket_info),
dest_placement_rule(_dest_placement_rule),
key(_key),
+ dest_key(_dest_key),
versioned_epoch(_versioned_epoch),
copy_if_newer(_if_newer), req(NULL), zones_trace(_zones_trace) {}
int send_request() override {
req = new RGWAsyncFetchRemoteObj(this, stack->create_completion_notifier(), store,
source_zone, bucket_info, dest_placement_rule,
- key, versioned_epoch, copy_if_newer, zones_trace);
+ key, dest_key, versioned_epoch, copy_if_newer, zones_trace);
async_rados->queue(req);
return 0;
}
{
return new RGWFetchRemoteObjCR(sync_env->async_rados, sync_env->store, sync_env->source_zone, bucket_info,
std::nullopt,
- key, versioned_epoch,
+ key, std::nullopt, versioned_epoch,
true, zones_trace);
}
void init(RGWDataSyncEnv *sync_env, uint64_t instance_id) override;
- RGWCoroutine *sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, uint64_t versioned_epoch, rgw_zone_set *zones_trace) override;
+ RGWCoroutine *sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, std::optional<uint64_t> versioned_epoch, rgw_zone_set *zones_trace) override;
RGWCoroutine *remove_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, real_time& mtime, bool versioned, uint64_t versioned_epoch, rgw_zone_set *zones_trace) override;
RGWCoroutine *create_delete_marker(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, real_time& mtime,
rgw_bucket_entry_owner& owner, bool versioned, uint64_t versioned_epoch, rgw_zone_set *zones_trace) override;
//current_meta_mgr = new_meta_mgr;
}
-RGWCoroutine *RGWArchiveDataSyncModule::sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, uint64_t versioned_epoch, rgw_zone_set *zones_trace)
+RGWCoroutine *RGWArchiveDataSyncModule::sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, std::optional<uint64_t> versioned_epoch, rgw_zone_set *zones_trace)
{
- ldout(sync_env->cct, 0) << "SYNC_ARCHIVE: sync_object: b=" << bucket_info.bucket << " k=" << key << " versioned_epoch=" << versioned_epoch << dendl;
+ ldout(sync_env->cct, 0) << "SYNC_ARCHIVE: sync_object: b=" << bucket_info.bucket << " k=" << key << " versioned_epoch=" << versioned_epoch.value_or(0) << dendl;
if (!bucket_info.versioned() ||
(bucket_info.flags & BUCKET_VERSIONS_SUSPENDED)) {
ldout(sync_env->cct, 0) << "SYNC_ARCHIVE: sync_object: enabling object versioning for archive bucket" << dendl;
return NULL;
}
}
- return new RGWFetchRemoteObjCR(sync_env->async_rados, sync_env->store, sync_env->source_zone, bucket_info,
- key, versioned_epoch,
+
+ std::optional<rgw_obj_key> dest_key;
+
+ if (versioned_epoch.value_or(0) == 0) { /* force version if not set */
+ versioned_epoch = 0;
+ dest_key = key;
+ if (key.instance.empty()) {
+ sync_env->store->gen_rand_obj_instance_name(&(*dest_key));
+ }
+ }
+
+ return new RGWFetchRemoteObjCR(sync_env->async_rados, sync_env->store, sync_env->source_zone,
+ bucket_info, std::nullopt,
+ key, dest_key, versioned_epoch,
true, zones_trace);
}
class RGWArchiveSyncModule : public RGWDefaultSyncModule {
public:
RGWArchiveSyncModule() {}
+ bool supports_writes() override { return false; }
bool supports_data_export() override { return false; }
int create_instance(CephContext *cct, const JSONFormattable& config, RGWSyncModuleInstanceRef *instance) override;
};
return 0;
}
-void RGWRados::gen_rand_obj_instance_name(rgw_obj *target_obj)
+void RGWRados::gen_rand_obj_instance_name(rgw_obj_key *target_key)
{
#define OBJ_INSTANCE_LEN 32
char buf[OBJ_INSTANCE_LEN + 1];
gen_rand_alphanumeric_no_underscore(cct, buf, OBJ_INSTANCE_LEN); /* don't want it to get url escaped,
no underscore for instance name due to the way we encode the raw keys */
- target_obj->key.set_instance(buf);
+ target_key->set_instance(buf);
+}
+
+void RGWRados::gen_rand_obj_instance_name(rgw_obj *target_obj)
+{
+ gen_rand_obj_instance_name(&target_obj->key);
}
int RGWRados::get_olh(const RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWOLHInfo *olh)
int follow_olh(const RGWBucketInfo& bucket_info, RGWObjectCtx& ctx, RGWObjState *state, const rgw_obj& olh_obj, rgw_obj *target);
int get_olh(const RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWOLHInfo *olh);
+ void gen_rand_obj_instance_name(rgw_obj_key *target_key);
void gen_rand_obj_instance_name(rgw_obj *target);
int update_containers_stats(map<string, RGWBucketEnt>& m);