initialized = true;
}
+ void set_epoch(uint64_t epoch) {
+ instance_entry.versioned_epoch = epoch;
+ }
int unlink_list_entry() {
string list_idx;
return ret;
}
- ret = olh.init(NULL);
+ bool olh_found;
+ ret = olh.init(&olh_found);
if (ret < 0) {
CLS_LOG(0, "ERROR: olh.init() returned ret=%d", ret);
return ret;
}
+ if (!olh_found) {
+ bool instance_only = false;
+ cls_rgw_obj_key key(dest_key.name);
+ ret = convert_plain_entry_to_versioned(hctx, key, true, instance_only);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: convert_plain_entry_to_versioned ret=%d", ret);
+ return ret;
+ }
+ olh.update(dest_key, false);
+ olh.set_tag(op.olh_tag);
+
+ obj.set_epoch(1);
+ }
+
if (!olh.start_modify(op.olh_epoch)) {
ret = obj.unlink_list_entry();
if (ret < 0) {
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid,
const cls_rgw_obj_key& key, const string& op_tag,
- uint64_t olh_epoch, bool log_op)
+ const string& olh_tag, uint64_t olh_epoch, bool log_op)
{
bufferlist in, out;
struct rgw_cls_unlink_instance_op call;
call.key = key;
call.op_tag = op_tag;
call.olh_epoch = olh_epoch;
+ call.olh_tag = olh_tag;
call.log_op = log_op;
::encode(call, in);
int r = io_ctx.exec(oid, "rgw", "bucket_unlink_instance", in, out);
bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op);
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, const string& op_tag,
- uint64_t olh_epoch, bool log_op);
+ const string& olh_tag, uint64_t olh_epoch, bool log_op);
int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker,
const string& olh_tag,
map<uint64_t, vector<struct rgw_bucket_olh_log_entry> > *log, bool *is_truncated);
uint64_t olh_epoch;
bool log_op;
uint16_t bilog_flags;
+ string olh_tag;
rgw_cls_unlink_instance_op() : olh_epoch(0), log_op(false), bilog_flags(0) {}
void encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
+ ENCODE_START(2, 1, bl);
::encode(key, bl);
::encode(op_tag, bl);
::encode(olh_epoch, bl);
::encode(log_op, bl);
::encode(bilog_flags, bl);
+ ::encode(olh_tag, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
- DECODE_START(1, bl);
+ DECODE_START(2, bl);
::decode(key, bl);
::decode(op_tag, bl);
::decode(olh_epoch, bl);
::decode(log_op, bl);
::decode(bilog_flags, bl);
+ if (struct_v >= 2) {
+ ::decode(olh_tag, bl);
+ }
DECODE_FINISH(bl);
}
op.cmpxattr(RGW_ATTR_OLH_ID_TAG, CEPH_OSD_CMPXATTR_OP_EQ, olh_state.olh_tag);
}
-int RGWRados::bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, uint64_t olh_epoch)
+int RGWRados::bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch)
{
rgw_rados_ref ref;
rgw_bucket bucket;
}
cls_rgw_obj_key key(obj_instance.get_index_key_name(), obj_instance.get_instance());
- ret = cls_rgw_bucket_unlink_instance(bs.index_ctx, bs.bucket_obj, key, op_tag, olh_epoch, get_zone().log_data);
+ ret = cls_rgw_bucket_unlink_instance(bs.index_ctx, bs.bucket_obj, key, op_tag, olh_tag, olh_epoch, get_zone().log_data);
if (ret < 0) {
return ret;
}
return ret;
}
- ret = bucket_index_unlink_instance(target_obj, op_tag, olh_epoch);
+ string olh_tag(state->olh_tag.c_str(), state->olh_tag.length());
+
+ ret = bucket_index_unlink_instance(target_obj, op_tag, olh_tag, olh_epoch);
if (ret < 0) {
ldout(cct, 20) << "bucket_index_link_olh() target_obj=" << target_obj << " returned " << ret << dendl;
if (ret == -ECANCELED) {
const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch,
ceph::real_time unmod_since, bool high_precision_time);
- int bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, uint64_t olh_epoch);
+ int bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch);
int bucket_index_read_olh_log(RGWObjState& state, rgw_obj& obj_instance, uint64_t ver_marker,
map<uint64_t, vector<rgw_bucket_olh_log_entry> > *log, bool *is_truncated);
int bucket_index_trim_olh_log(RGWObjState& obj_state, rgw_obj& obj_instance, uint64_t ver);