#include "include/utime.h"
+void rgw_zone_set_entry::from_str(const string& s)
+{
+ auto pos = s.find(':');
+ if (pos == string::npos) {
+ zone = s;
+ location_key.reset();
+ } else {
+ zone = s.substr(0, pos);
+ location_key = s.substr(pos + 1);
+ }
+}
+
+string rgw_zone_set_entry::to_str() const
+{
+ string s = zone;
+ if (location_key) {
+ s = s + ":" + *location_key;
+ }
+ return s;
+}
+
+void rgw_zone_set_entry::encode(bufferlist &bl) const
+{
+ /* no ENCODE_START, ENCODE_END for backward compatibility */
+ ceph::encode(to_str(), bl);
+}
+
+void rgw_zone_set_entry::decode(bufferlist::const_iterator &bl)
+{
+ /* no DECODE_START, DECODE_END for backward compatibility */
+ string s;
+ ceph::decode(s, bl);
+ from_str(s);
+}
+
+void rgw_zone_set_entry::dump(Formatter *f) const
+{
+ encode_json("entry", to_str(), f);
+}
+
+void rgw_zone_set_entry::decode_json(JSONObj *obj) {
+ string s;
+ JSONDecoder::decode_json("entry", s, obj);
+ from_str(s);
+}
+
+void rgw_zone_set::insert(const string& zone, std::optional<string> location_key)
+{
+ entries.insert(rgw_zone_set_entry(zone, location_key));
+}
+
+bool rgw_zone_set::exists(const string& zone, std::optional<string> location_key) const
+{
+ return entries.find(rgw_zone_set_entry(zone, location_key)) != entries.end();
+}
+
+void encode_json(const char *name, const rgw_zone_set& zs, ceph::Formatter *f)
+{
+ Formatter::ArraySection as(*f, name);
+ for (auto& e : zs.entries) {
+ encode_json("entry", e, f);
+ }
+}
+
+void decode_json_obj(rgw_zone_set& zs, JSONObj *obj)
+{
+ decode_json_obj(zs.entries, obj);
+}
+
void rgw_bucket_pending_info::generate_test_instances(list<rgw_bucket_pending_info*>& o)
{
rgw_bucket_pending_info *i = new rgw_bucket_pending_info;
}
using ceph::operator <<;
-using rgw_zone_set = std::set<std::string>;
+struct rgw_zone_set_entry {
+ string zone;
+ std::optional<std::string> location_key;
+
+ bool operator<(const rgw_zone_set_entry& e) const {
+ if (zone < e.zone) {
+ return true;
+ }
+ if (zone > e.zone) {
+ return false;
+ }
+ return (location_key < e.location_key);
+ }
+
+ rgw_zone_set_entry() {}
+ rgw_zone_set_entry(const string& _zone,
+ std::optional<std::string> _location_key) : zone(_zone),
+ location_key(_location_key) {}
+ rgw_zone_set_entry(const string& s) {
+ from_str(s);
+ }
+
+ void from_str(const string& s);
+ string to_str() const;
+
+ void encode(bufferlist &bl) const;
+ void decode(bufferlist::const_iterator &bl);
+
+ void dump(Formatter *f) const;
+ void decode_json(JSONObj *obj);
+};
+WRITE_CLASS_ENCODER(rgw_zone_set_entry)
+
+struct rgw_zone_set {
+ std::set<rgw_zone_set_entry> entries;
+
+ void encode(bufferlist &bl) const {
+ /* no ENCODE_START, ENCODE_END for backward compatibility */
+ ceph::encode(entries, bl);
+ }
+ void decode(bufferlist::const_iterator &bl) {
+ /* no DECODE_START, DECODE_END for backward compatibility */
+ ceph::decode(entries, bl);
+ }
+ void decode_json(JSONObj *obj);
+
+ void insert(const string& zone, std::optional<string> location_key);
+ bool exists(const string& zone, std::optional<string> location_key) const;
+};
+WRITE_CLASS_ENCODER(rgw_zone_set)
+
+/* backward compatibility, rgw_zone_set needs to encode/decode the same as std::set */
+void encode_json(const char *name, const rgw_zone_set& zs, ceph::Formatter *f);
+void decode_json_obj(rgw_zone_set& zs, JSONObj *obj);
+
enum RGWPendingState {
CLS_RGW_STATE_PENDING_MODIFY = 0,
data_sync_module = sync_env->sync_module->get_data_handler();
zones_trace = _zones_trace;
- zones_trace.insert(sync_env->svc->zone->get_zone().id);
+ zones_trace.insert(sync_env->svc->zone->get_zone().id, _sync_pipe.info.dest_bs.get_key());
}
int operate() override {
status_oid(status_oid),
tn(sync_env->sync_tracer->add_node(tn_parent, "full_sync",
SSTR(bucket_shard_str{bs}))) {
- zones_trace.insert(sc->source_zone);
+ zones_trace.insert(sc->source_zone, sync_pipe.info.dest_bs.bucket.get_key());
marker_tracker.set_tn(tn);
prefix_handler.set_rules(sync_pipe.get_rules());
}
bool updated_status{false};
const string& status_oid;
const string& zone_id;
+ string target_location_key;
string cur_id;
set_status("init");
marker_tracker.set_tn(tn);
rules = sync_pipe.get_rules();
+ target_location_key = sync_pipe.info.dest_bs.bucket.get_key();
}
bool check_key_handled(const rgw_obj_key& key) {
if (e.state != CLS_RGW_STATE_COMPLETE) {
continue;
}
- if (e.zones_trace.find(zone_id) != e.zones_trace.end()) {
+ if (e.zones_trace.exists(zone_id, target_location_key)) {
continue;
}
auto& squash_entry = squash_map[make_pair(e.object, e.instance)];
marker_tracker.try_update_high_marker(cur_id, 0, entry->timestamp);
continue;
}
- if (entry->zones_trace.find(zone_id) != entry->zones_trace.end()) {
+ if (entry->zones_trace.exists(zone_id, target_location_key)) {
set_status() << "redundant operation, skipping";
tn->log(20, SSTR("skipping object: "
<<bucket_shard_str{bs} <<"/"<<key<<": redundant operation"));
if (zones_trace) {
entry->zones_trace = *zones_trace;
} else {
- entry->zones_trace.insert(store->svc.zone->get_zone().id);
+ entry->zones_trace.insert(store->svc.zone->get_zone().id, obj.bucket.get_key());
}
*result = entry;
if (_zones_trace) {
zones_trace = *_zones_trace;
}
- zones_trace.insert(svc.zone->get_zone().id);
+ zones_trace.insert(svc.zone->get_zone().id, bucket_info.bucket.get_key());
BucketShard bs(this);
if (_zones_trace) {
zones_trace = *_zones_trace;
}
- zones_trace.insert(svc.zone->get_zone().id);
+ zones_trace.insert(svc.zone->get_zone().id, bucket_info.bucket.get_key());
BucketShard bs(this);
if (_zones_trace) {
zones_trace = *_zones_trace;
}
- zones_trace.insert(svc.zone->get_zone().id);
+ zones_trace.insert(svc.zone->get_zone().id, bs.bucket.get_key());
ObjectWriteOperation o;
cls_rgw_obj_key key(obj.key.get_index_key_name(), obj.key.instance);
if (_zones_trace) {
zones_trace = *_zones_trace;
}
- zones_trace.insert(svc.zone->get_zone().id);
+ zones_trace.insert(svc.zone->get_zone().id, bs.bucket.get_key());
rgw_bucket_entry_ver ver;
ver.pool = pool;