return 0;
}
+ rgw_bucket_dir_entry& get_dir_entry() {
+ return instance_entry;
+ }
+
void init_as_delete_marker(rgw_bucket_dir_entry_meta& meta) {
/* a deletion marker, need to initialize it, there's no instance entry for it yet */
instance_entry.key = key;
return ret;
}
- return 0;
+ struct rgw_bucket_dir_header header;
+ ret = read_bucket_header(hctx, &header);
+ if (ret < 0) {
+ CLS_LOG(1, "ERROR: rgw_bucket_unlink_instance(): failed to read header\n");
+ return ret;
+ }
+
+ if (op.log_op) {
+ rgw_bucket_dir_entry& entry = obj.get_dir_entry();
+
+ rgw_bucket_entry_ver ver;
+ ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch());
+
+ RGWModifyOp operation = (op.delete_marker ? CLS_RGW_OP_LINK_OLH_DM : CLS_RGW_OP_LINK_OLH);
+ ret = log_index_operation(hctx, op.key, operation, op.op_tag,
+ entry.meta.mtime, ver,
+ CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker);
+ if (ret < 0)
+ return ret;
+ }
+
+ return write_bucket_header(hctx, &header); /* updates header version */
}
static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
return ret;
}
- return 0;
+ struct rgw_bucket_dir_header header;
+ ret = read_bucket_header(hctx, &header);
+ if (ret < 0) {
+ CLS_LOG(1, "ERROR: rgw_bucket_unlink_instance(): failed to read header\n");
+ return ret;
+ }
+
+ if (op.log_op) {
+ rgw_bucket_entry_ver ver;
+ ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch());
+
+ utime_t mtime = ceph_clock_now(g_ceph_context); /* mtime has no real meaning in instance removal context */
+ ret = log_index_operation(hctx, op.key, CLS_RGW_OP_UNLINK_INSTANCE, op.op_tag,
+ mtime, ver,
+ CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker);
+ if (ret < 0)
+ return ret;
+ }
+
+ return write_bucket_header(hctx, &header); /* updates header version */
}
static int rgw_bucket_read_olh_log(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag,
bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
- uint64_t olh_epoch)
+ uint64_t olh_epoch, bool log_op)
{
bufferlist in, out;
struct rgw_cls_link_olh_op call;
call.meta = *meta;
}
call.olh_epoch = olh_epoch;
+ call.log_op = log_op;
::encode(call, in);
int r = io_ctx.exec(oid, "rgw", "bucket_link_olh", in, out);
if (r < 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)
+ 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.log_op = log_op;
::encode(call, in);
int r = io_ctx.exec(oid, "rgw", "bucket_unlink_instance", in, out);
if (r < 0)
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag,
bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
- uint64_t olh_epoch);
+ uint64_t olh_epoch, 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);
+ 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);
rgw_bucket_dir_entry_meta::generate_test_instances(l);
list<rgw_bucket_dir_entry_meta *>::iterator iter = l.begin();
op->meta = *(*iter);
+ op->log_op = true;
o.push_back(op);
::encode_json("op_tag", op_tag, f);
::encode_json("meta", meta, f);
::encode_json("olh_epoch", olh_epoch, f);
+ ::encode_json("log_op", log_op, f);
}
void rgw_cls_unlink_instance_op::generate_test_instances(list<rgw_cls_unlink_instance_op*>& o)
op->key.name = "name";
op->op_tag = "op_tag";
op->olh_epoch = 124;
+ op->log_op = true;
o.push_back(op);
::encode_json("key", key, f);
::encode_json("op_tag", op_tag, f);
::encode_json("olh_epoch", olh_epoch, f);
+ ::encode_json("log_op", log_op, f);
}
void rgw_cls_read_olh_log_op::generate_test_instances(list<rgw_cls_read_olh_log_op*>& o)
string op_tag;
struct rgw_bucket_dir_entry_meta meta;
uint64_t olh_epoch;
+ bool log_op;
- rgw_cls_link_olh_op() : delete_marker(false), olh_epoch(0) {}
+ rgw_cls_link_olh_op() : delete_marker(false), olh_epoch(0), log_op(false) {}
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
::encode(op_tag, bl);
::encode(meta, bl);
::encode(olh_epoch, bl);
+ ::encode(log_op, bl);
ENCODE_FINISH(bl);
}
::decode(op_tag, bl);
::decode(meta, bl);
::decode(olh_epoch, bl);
+ ::decode(log_op, bl);
DECODE_FINISH(bl);
}
cls_rgw_obj_key key;
string op_tag;
uint64_t olh_epoch;
+ bool log_op;
- rgw_cls_unlink_instance_op() : olh_epoch(0) {}
+ rgw_cls_unlink_instance_op() : olh_epoch(0), log_op(false) {}
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
::encode(key, bl);
::encode(op_tag, bl);
::encode(olh_epoch, bl);
+ ::encode(log_op, bl);
ENCODE_FINISH(bl);
}
::decode(key, bl);
::decode(op_tag, bl);
::decode(olh_epoch, bl);
+ ::decode(log_op, bl);
DECODE_FINISH(bl);
}
case CLS_RGW_OP_UNKNOWN:
f->dump_string("op", "unknown");
break;
+ case CLS_RGW_OP_LINK_OLH:
+ f->dump_string("op", "link_olh");
+ break;
+ case CLS_RGW_OP_LINK_OLH_DM:
+ f->dump_string("op", "link_olh_del");
+ break;
+ case CLS_RGW_OP_UNLINK_INSTANCE:
+ f->dump_string("op", "unlink_instance");
+ break;
default:
f->dump_string("op", "invalid");
break;
CLS_RGW_OP_DEL = 1,
CLS_RGW_OP_CANCEL = 2,
CLS_RGW_OP_UNKNOWN = 3,
+ CLS_RGW_OP_LINK_OLH = 4,
+ CLS_RGW_OP_LINK_OLH_DM = 5, /* creation of delete marker */
+ CLS_RGW_OP_UNLINK_INSTANCE = 6,
};
struct rgw_bucket_pending_info {
}
cls_rgw_obj_key key(obj_instance.get_index_key_name(), obj_instance.get_instance());
- ret = cls_rgw_bucket_link_olh(index_ctx, oid, key, olh_state.olh_tag, delete_marker, op_tag, meta, olh_epoch);
+ ret = cls_rgw_bucket_link_olh(index_ctx, oid, key, olh_state.olh_tag, delete_marker, op_tag, meta, olh_epoch,
+ zone_public_config.log_data);
if (ret < 0) {
return ret;
}
}
cls_rgw_obj_key key(obj_instance.get_index_key_name(), obj_instance.get_instance());
- ret = cls_rgw_bucket_unlink_instance(index_ctx, oid, key, op_tag, olh_epoch);
+ ret = cls_rgw_bucket_unlink_instance(index_ctx, oid, key, op_tag, olh_epoch, zone_public_config.log_data);
if (ret < 0) {
return ret;
}