@@ -4317,7 +4317,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& dest_obj_ctx,
43174317 RGWFetchObjFilter *filter,
43184318 bool stat_follow_olh,
43194319 const rgw_obj& stat_dest_obj,
4320- const rgw_zone_set_entry& source_trace_entry,
4320+ std::optional< rgw_zone_set_entry> source_trace_entry,
43214321 rgw_zone_set *zones_trace,
43224322 std::optional<uint64_t>* bytes_transferred)
43234323{
@@ -4559,32 +4559,39 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& dest_obj_ctx,
45594559 // erase the append attr
45604560 cb.get_attrs ().erase (RGW_ATTR_APPEND_PART_NUM);
45614561
4562- { // add x-amz-replication-status=REPLICA
4563- auto & bl = cb.get_attrs ()[RGW_ATTR_OBJ_REPLICATION_STATUS];
4564- bl.clear (); // overwrite source's status
4565- bl.append (" REPLICA" );
4566- }
4567- { // update replication trace
4568- std::vector<rgw_zone_set_entry> trace;
4569- if (auto i = cb.get_attrs ().find (RGW_ATTR_OBJ_REPLICATION_TRACE);
4570- i != cb.get_attrs ().end ()) {
4571- try {
4572- decode (trace, i->second );
4573- } catch (const buffer::error&) {}
4562+ if (source_trace_entry) { // replication attrs only if we are replicating
4563+ { // add x-amz-replication-status=REPLICA
4564+ auto & bl = cb.get_attrs ()[RGW_ATTR_OBJ_REPLICATION_STATUS];
4565+ bl.clear (); // overwrite source's status
4566+ bl.append (" REPLICA" );
45744567 }
4575- // add the source entry to the end
4576- trace.push_back (source_trace_entry);
4568+ { // update replication trace
4569+ std::vector<rgw_zone_set_entry> trace;
4570+ if (auto i = cb.get_attrs ().find (RGW_ATTR_OBJ_REPLICATION_TRACE);
4571+ i != cb.get_attrs ().end ()) {
4572+ try {
4573+ decode (trace, i->second );
4574+ } catch (const buffer::error&) {}
4575+ }
4576+ // add the source entry to the end
4577+ trace.push_back (*source_trace_entry);
45774578
4578- bufferlist bl;
4579- encode (trace, bl);
4580- cb.get_attrs ()[RGW_ATTR_OBJ_REPLICATION_TRACE] = std::move (bl);
4581- }
4582- {
4583- // add x-amz-replicated-at
4584- bufferlist bl;
4585- ceph::real_time timestamp = real_clock::now ();
4586- encode (timestamp, bl);
4587- cb.get_attrs ()[RGW_ATTR_OBJ_REPLICATION_TIMESTAMP] = std::move (bl);
4579+ bufferlist bl;
4580+ encode (trace, bl);
4581+ cb.get_attrs ()[RGW_ATTR_OBJ_REPLICATION_TRACE] = std::move (bl);
4582+ }
4583+ {
4584+ // add x-amz-replicated-at
4585+ bufferlist bl;
4586+ ceph::real_time timestamp = real_clock::now ();
4587+ encode (timestamp, bl);
4588+ cb.get_attrs ()[RGW_ATTR_OBJ_REPLICATION_TIMESTAMP] = std::move (bl);
4589+ }
4590+ } else {
4591+ // remove replication attrs
4592+ cb.get_attrs ().erase (RGW_ATTR_OBJ_REPLICATION_STATUS);
4593+ cb.get_attrs ().erase (RGW_ATTR_OBJ_REPLICATION_TRACE);
4594+ cb.get_attrs ().erase (RGW_ATTR_OBJ_REPLICATION_TIMESTAMP);
45884595 }
45894596
45904597 if (source_zone.empty ()) {
@@ -4814,7 +4821,6 @@ int RGWRados::copy_obj(RGWObjectCtx& src_obj_ctx,
48144821 ldpp_dout (dpp, 5 ) << " Copy object " << src_obj.bucket << " :" << src_obj.get_oid () << " => " << dest_obj.bucket << " :" << dest_obj.get_oid () << dendl;
48154822
48164823 if (remote_src || !source_zone.empty ()) {
4817- rgw_zone_set_entry source_trace_entry{source_zone.id , std::nullopt };
48184824 // null_yield resolves a crash when calling progress_cb(), because the beast
48194825 // frontend tried to use this same yield context to write the progress
48204826 // response to the frontend socket. call fetch_remote_obj() synchronously so
@@ -4826,7 +4832,7 @@ int RGWRados::copy_obj(RGWObjectCtx& src_obj_ctx,
48264832 unmod_ptr, high_precision_time,
48274833 if_match, if_nomatch, attrs_mod, copy_if_newer, attrs, category,
48284834 olh_epoch, delete_at, ptag, petag, progress_cb, progress_data, rctx,
4829- nullptr /* filter */ , stat_follow_olh, stat_dest_obj, source_trace_entry );
4835+ nullptr /* filter */ , stat_follow_olh, stat_dest_obj, std:: nullopt );
48304836 }
48314837
48324838 map<string, bufferlist> src_attrs;
0 commit comments