update_olh_log(olh_data_entry, op, op_tag, key, delete_marker);
}
+ bool exists() { return olh_data_entry.exists; }
+
+ void set_exists(bool exists) {
+ olh_data_entry.exists = exists;
+ }
};
/*
}
if (olh_found) {
- /* found olh, previous instance is no longer the latest, need to update */
- BIVerObjEntry old_obj(hctx, olh.get_entry().key);
+ if (olh.exists()) {
+ /* found olh, previous instance is no longer the latest, need to update */
+ BIVerObjEntry old_obj(hctx, olh.get_entry().key);
- ret = old_obj.demote_current();
- if (ret < 0) {
- CLS_LOG(0, "ERROR: could not demote current on previous key ret=%d", ret);
- return ret;
+ ret = old_obj.demote_current();
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: could not demote current on previous key ret=%d", ret);
+ return ret;
+ }
}
} else {
cls_rgw_obj_key key(op.key.name);
olh.update(op.key, op.delete_marker);
+ olh.set_exists(true);
+
ret = olh.write();
if (ret < 0) {
CLS_LOG(0, "ERROR: failed to update olh ret=%d", ret);
next_key.name.c_str(), next_key.instance.c_str(), (int)next.is_delete_marker());
olh.update(next_key, next.is_delete_marker());
-
olh.update_log(CLS_RGW_OLH_OP_LINK_OLH, op.op_tag, next_key, next.is_delete_marker());
+ } else {
+ /* next_key is empty */
+ olh.update(next_key, false);
+ olh.update_log(CLS_RGW_OLH_OP_UNLINK_OLH, op.op_tag, next_key, false);
+ olh.set_exists(false);
}
}
encode_json("delete_marker", delete_marker, f);
encode_json("epoch", epoch, f);
encode_json("pending_log", pending_log, f);
+ encode_json("tag", tag, f);
+ encode_json("exists", exists, f);
}
void rgw_bucket_olh_log_entry::dump(Formatter *f) const
enum OLHLogOp {
CLS_RGW_OLH_OP_LINK_OLH = 1,
- CLS_RGW_OLH_OP_REMOVE_INSTANCE = 2,
+ CLS_RGW_OLH_OP_UNLINK_OLH = 2, /* object does not exist */
+ CLS_RGW_OLH_OP_REMOVE_INSTANCE = 3,
};
struct rgw_bucket_olh_log_entry {
uint64_t epoch;
map<uint64_t, struct rgw_bucket_olh_log_entry> pending_log;
string tag;
+ bool exists;
- rgw_bucket_olh_entry() : delete_marker(false), epoch(0) {}
+ rgw_bucket_olh_entry() : delete_marker(false), epoch(0), exists(false) {}
void encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
::encode(epoch, bl);
::encode(pending_log, bl);
::encode(tag, bl);
+ ::encode(exists, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator &bl) {
::decode(epoch, bl);
::decode(pending_log, bl);
::decode(tag, bl);
+ ::decode(exists, bl);
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;